How to Set Up Docker in Proxmox

  • Post author:WunderTech
  • Post published:December 11, 2022
  • Post last modified:May 27, 2024
  • Post category:Proxmox
  • Reading time:13 mins read

Share what you're reading!

In this tutorial, we will look at how to set up Docker in Proxmox. Running Docker containers using Proxmox is an extremely beneficial way to utilize your hypervisor. Especially if you use an LXC container which will drastically reduce system resources.

How to Set Up Docker in Proxmox

We will look at how to set up Docker in Proxmox below using an LXC container and a virtual machine (VM). It is recommended by the Proxmox team to use a VM as opposed to an LXC for long-term stability.

Utilizing an LXC Container for Docker

The process below will utilize an LXC container and Ubuntu 22.04 for Docker, however, you can really use any distribution that you’d like.

1. Log in to Proxmox, select the storage location where you’d like to store the container template, select CT Templates, then select Templates.

container template screen in proxmox. how to set up docker in proxmox

2. Search for Ubuntu, then select ubuntu-22.04 and Download. For the operating system, you can realistically select any Debian-based OS (I used to use Debian), but I’ve found the performance of Ubuntu to be significantly better.

downloading the template.

3. After the template finishes downloading, select Create CT to create a new container.

creating a container in proxmox.

4. Enter a Hostname, then enter the Password you’d like to use. This password will be used to log in to the root user account. After all the settings have been specified, select Next.

NOTE: Make sure the container stays as unprivileged. You do not want to run Docker in a privileged LXC Container for security reasons.

lxc container creation for debian 11.

5. Select the Ubuntu Template, then select Next to proceed.

ubuntu template.

6. Select the Disk Size for this container, then select Next.

lxc container hard drive size.

7. Select the total Cores for the CPU, then select Next.

lxc container cpu entry.

8. Set the total Memory, then select Next.

NOTE: Please keep in mind that this is the limit that this container can use.

lxc container memory selection.

9. Change the Network to use DHCP for IPv4 and IPv6 (unless you want to specify them manually), then select Next until you get to Confirm.

NOTE: We are skipping the DNS section, but you can change these settings if you’d like to use a DNS server different than the Proxmox host.

lxc container network settings.

10. Confirm the settings, then select Finish to create the container!

lxc container confirmation settings.

11. Select the LXC Container we just created, then select Options and Edit the Features.

container options.

12. Enable keyctl, then select OK. You can now start the container!

container keyctl

13. After the container starts, log in with the username root and password set in step four. Run the command below to update the system.

apt update && apt upgrade -y
update container command.

14. After the system is updated, run each of the commands below one by one. These are taken directly from the official Docker documentation and are the prerequisites needed to install the latest version of Docker in Proxmox.

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

After the commands above are run, copy and run the entire command below.

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Finally, update the system.

sudo apt-get update

15. After all of the commands above have been run, run the command below to install Docker!

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
command to install docker.

16. At this point, Docker is fully configured and you’ll be able to create Docker containers. However, if you’d like a GUI, you can install Portainer using the command below.

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

17. If you did install Portainer (and after it’s created), you’ll be able to access Portainer using the IP address of the container and port 9000.

https://[CONTAINER_IP]:9443

Utilizing a Virtual Machine for Docker in Proxmox

If you’d rather install Docker in Proxmox with a Virtual Machine, you can do that as well. This tutorial utilizes Ubuntu Server, but you can use just about any distribution you’d like.

1. Download the ISO image of the operating system you’d like to install, select Create VM, then give the VM a name and select Next.

proxmox virtual machine creation.

2. Select the Storage location, then the ISO Image, and select Next.

proxmox operating system selection.

3. Change the System, Disks, CPU, Memory, and Network. After all of the settings have been configured to your specifications, confirm the settings and create the VM!

proxmox virtual machine creation confirmation.

4. Install the Operating System and then log in after it’s fully installed. When ready, run the command below to install Docker!

NOTE: Please keep in mind that this is a script and while the process is automated, you should trust the origin of the script before you run it. I highly suggest that you review the script before running it. After the script is run, Docker will be installed!

curl -sSL https://get.docker.com/ | sh
proxmox docker curl command.

16. At this point, Docker is fully configured and you’ll be able to create Docker containers. However, if you’d like a GUI, you can install Portainer using the command below.

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

17. If you did install Portainer and after it’s created, you’ll be able to access Portainer using the IP address of the container and port 9000.

https://[CONTAINER_IP]:9443

Conclusion & Final Thoughts: Proxmox Docker

This tutorial looked at how to set up Docker in Proxmox. The biggest question you’ll have to answer is if you want to use an LXC container or virtual machine. The actual setup process (from a Docker perspective) is very similar for each method, however, the Proxmox process of setting up the LXC container or VM is where the steps differ. After using both methods, you should have a functional Docker setup that you can utilize!