Docker Logo

Installing Docker as an LXC Container in Proxmox VE – Debian 10 / 11

Docker Logo

While LXC Containers are my general preference by virtue of the built-in support in Proxmox VE as well as the more open nature of such containers, sometimes it is necessary to run Docker because the solution you are looking for just does not deploy in LXC.

For this reason, I have found it necessary to describe the fairly simple process of deploying Docker inside of an LXC Container without the security risk that running that container as unprivileged.

 

  1. Step 1 – Create an LXC Container running Debian through the Proxmox VE GUI (In our example the container CTID is 100), it should not be a privileged container.
  2. Step 2 – Enable the Container features (Nesting and Keyctl) that Docker requires in the LXC Container:
    • As the Proxmox VE GUI only allows these settings to be changed graphically as root, if you are not the root user, login on the Proxmox VE Host using SSH or your method of choice.
    • Edit the Container .conf file using your editor of choice (Replace 100 with the CTID of the Container you created in Step 1:

      nano /etc/pve/lxc/100.conf
    • Add the “features: nesting=1,keyctl=1” line at the end of the .conf file:

      arch: amd64
      cores: 4
      hostname: docker
      memory: 4096
      net0: name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.x,hwaddr=XX:XX:XX:XX:XX:XX$
      onboot: 1
      ostype: debian
      rootfs: local-lvm:vm-100-disk-0,size=100G
      startup: order=1,up=10
      swap: 2048
      unprivileged: 1
      features: nesting=1,keyctl=1
    • Close Nano with ctrl+x and select y to save changes.
  3. Step 3 – Install prerequisites:
    • After starting the container and logging into the container with PCT enter:

      apt update && apt upgrade -y
      apt install apt-transport-https ca-certificates curl gnupg1 lsb-release software-properties-common -y
  4. Step 4 – Install Apt Repository for Docker:

    curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
    add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
  5. Step 5 – Installing Docker

    apt update && apt install docker-ce docker-ce-cli containerd.io -y

It’s that simple, now you have docker running in your container.

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *