How to create unprivileged LXC container on Ubuntu Linux 14.04 LTS

To create an unprivileged LXC container on Ubuntu 14.04 LTS, follow these steps:

  1. Install the LXC package:
sudo apt-get update
sudo apt-get install lxc
  1. Create the container configuration file:
sudo lxc-create -n <container-name> -t download -- --dist ubuntu --release trusty --arch amd64

This will create a container based on Ubuntu 14.04 LTS (trusty) with the architecture amd64. Replace <container-name> with the desired name for the container.

  1. Configure the container to run as an unprivileged user:
sudo nano /var/lib/lxc/<container-name>/config

In the configuration file, add the following line:

lxc.id_map = u 0 100000 65536
lxc.id_map = g 0 100000 65536

This sets the UID and GID map for the container, so that it runs as an unprivileged user.

  1. Start the container:
sudo lxc-start -n <container-name>

This will start the container and you should be able to log in and use it as an unprivileged user.

Note that these steps are a basic example and may need to be adjusted for your specific use case. For more information, you should refer to the official LXC documentation.

Leave a Comment