Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 81 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 82 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 81 Warning: count(): Parameter must be an array or an object that implements Countable in /customers/d/f/8/sveitech.dk/httpd.www/wp-content/plugins/css-javascript-toolbox/framework/events/subjects/hook.subject.php on line 82 LXC – Linux Containers | Sveitech

LXC – Linux Containers

Creating containers

sudo lxc-create -t ubuntu -n example_container

This creates a container based on the current ubuntu installation, and names it example_container. The container is placed in /var/lib/lxc/example_container, and the root file system is placed in /var/lib/lxc/example_container/rootfs.


sudo lxc-create -t ubuntu -n example_container -P /opt/lxc_containers --dir=/opt/lxc_containers/example_container/rootfs

This creates a container based on the current ubuntu installation, and names it example_container. The container configuration files are placed in /opt/lxc_containers/example_container and the root file system is placed in /opt/lxc_container/example_container/rootfs

Listing containers

#lists all containers found in /var/lib/lxc.
sudo lxc-ls --fancy

#lists all containers found in /opt/lxc_containers.
sudo lxc-ls -P /opt/lxc_containers --fancy

Starting containers

# Start container in the background
sudo lxc-start -n example_container -d

# Access the container by attaching to the containers console.
# CTRL-a, q detaches again.
sudo lxc-console -n example_container

# ssh into container
ssh ubuntu@<ip>

Stopping containers

# Turn machine off, from inside the machine
sudo poweroff

# Kill machine from outside (cleanly)
sudo lxc-stop -n example_container

# Force kill machine from outside
sudo lxc-stop -n example_container -k

Sveistrup Technologies