LXC Alpinelinux Simple: Difference between revisions
m (add rootfs download) |
m (add draft) |
||
Line 1: | Line 1: | ||
{{ | {{Pill||DRAFT|goldenrod|yellow}} | ||
[https://linuxcontainers.org/ Linux Containers (LXC)] provides containers similar to BSD Jails, Linux VServers and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the "host". | [https://linuxcontainers.org/ Linux Containers (LXC)] provides containers similar to BSD Jails, Linux VServers and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the "host". | ||
Revision as of 17:12, 25 August 2025
DRAFT
Linux Containers (LXC) provides containers similar to BSD Jails, Linux VServers and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the "host".
Setup walkthrough
Basic setup that gets you going, you would still need to read main LXC documentations for advanced features.
Objective
- Install Alpinelinux.
- Install LXC and its dependencies.
- Download required files.
- Start a LXC instance.
- Test basic networking.
Test bed
WIP
- Describe here the test bed/setup used to run the scripts below.
- MODEL: Dell Laptop.
- CPU: Intel i5 2nd/3rd generation with virtualization enabled.
- RAM: 8GB
Install Alpinelinux
- Diskless installs (Ram based)
- SYS installs
Install LXC and its dependencies
v3.21.x-v3.22.x
Install the required packages (as root):
apk add lxc lxcfs bridge
Setup LXC
-v3.22.x
Get required files (as root):
cd ~ wget https://dl-cdn.alpinelinux.org/v3.21/releases/x86_64/alpine-minirootfs-3.21.1-x86_64.tar.gz cd /var/lib/lxc/ mkdir -p guest1/rootfs cd guest1/rootfs tar -zxf ~/alpine-minirootfs-3.21.1-x86_64.tar.gz apk add --root ./ alpine-base
v3.21.x-v3.22.x
Fix some issues (as root),
#### Minor/manual changes #### rm -f /var/lib/lxc/guest1/rootfs/dev/null rm -f /var/lib/lxc/guest1/rootfs/dev/zero
v3.21.x-v3.22.x
Content of /etc/lxc/bridgenat.conf. (Not needed for manual setup)
lxc.net.0.type = veth lxc.net.0.flags = up lxc.net.0.link = br0 lxc.net.0.name = eth1 lxc.net.0.ipv4.address = 192.168.10.2/24 192.168.1.255 lxc.net.0.ipv4.gateway = 192.168.10.1 lxc.net.0.veth.pair = veth-if-10
v3.21.x-v3.22.x
Content of guest1/config
# config file that was generated using # 'lxc-create -n alpine -f /etc/lxc/bridgenat.conf -t alpine' lxc.net.0.type = veth lxc.net.0.flags = up lxc.net.0.link = br0 lxc.net.0.name = eth1 lxc.net.0.ipv4.address = 192.168.10.10/24 192.168.10.255 lxc.net.0.ipv4.gateway = 192.168.10.1 # needs to be uniq per guest lxc.net.0.veth.pair = veth-if-10 lxc.rootfs.path = dir:/var/lib/lxc/guest1/rootfs # Specify container architecture. lxc.arch = x86_64 # Set hostname. lxc.uts.name = guest1 # If something doesn't work, try to comment this out. lxc.cap.drop = sys_admin # Comment this out if you have to debug processes by tracing. lxc.cap.drop = sys_ptrace # Comment this out if required by your applications. lxc.cap.drop = setpcap # Include common configuration. lxc.include = /usr/share/lxc/config/alpine.common.conf
v3.21.x-v3.22.x
Start a LXC instance
rc-service lxc.guest1 start
v3.21.x-v3.22.x
Use LXC
lxc-attach -n guest1 passwd root # add a passwd exit lxc-console -n guest1 # this works !!!, need to create user first then su -l to root # OR use lxc-attach to change passwd of root
v3.21.x-v3.22.x
WIP
Fix some basic networkings
# brctl show bridge name bridge id STP enabled interfaces br0 8000.4686bf1982a3 no dummy0 veth-if-10