Linux Containers (LXC) provides containers similar BSD Jails, Linux VServer and Solaris Zones. It gives the impression of virtualization, but shares the kernel and resources with the "host".
NOTE: Simple (howto) is meant for using LXC for quick installation of applications using HOSTs networking/ip (container config has,
lxc.network.type = none ) and usage of application for development work. Most application have internal settings for PORTs which will be used where multiple versions of that application is needed to install.
For production or live environment using bridge (br0) with full networking for container would be ideal, alternate use docker (both requires some experience with container technologies).
Target audience: Developers, Newbies
Tested on: AlpineLinux v3.3x(host+guest)
Install the required packages:
Create a simple configuration template for the guests, /etc/lxc/simple.conf:
lxc.network.type = none
Create a guest
Using Alpine Template
This will create a /var/lib/lxc/dev1 directory with a config file and a rootfs directory.
If running on x86_64 architecture, it is possible to create a 32bit guest:
Starting/Stopping the guest
Create a symlink to the /etc/init.d/lxc script for your guest.
You can start your guest with:
Stop it with:
Make it autostart on boot up with:
You can also add to the container config:
lxc.start.auto = 1
to autostart containers by the lxc service only.
Connecting to the guest
By default sshd is not installed, so you will have to connect to a virtual console. This is done with:
To disconnect from it, press+
Deleting a guest
Make sure the guest is stopped before removal:
This will erase everything, without asking any questions. It is equivalent to: