How to Install Docker in a Proxmox LXC Container (Ubuntu 22.04 Guide)

What is Docker?

Docker is an open-source platform for container virtualization. With Docker, applications can run in isolated containers that include all necessary dependencies. This makes them platform-independent and easy to manage. Unlike traditional virtual machines (VMs), Docker utilizes the host system’s resources more efficiently since containers do not require their own kernel but instead share the host’s kernel.

What are the advantages of using Docker in an LXC container over a VM?

Using Docker in an LXC container has several advantages over a traditional VM:

  • Lower resource consumption: Since LXC containers do not start their own kernel, they require less RAM and CPU power compared to a VM.
  • Faster deployment: LXC containers start within seconds, whereas VMs usually take longer to boot.
  • Better integration: Docker containers running inside an LXC container are closer to the host system, enabling more efficient resource utilization.
  • Easier management: The combination of LXC and Docker simplifies managing multiple isolated applications without the overhead costs of a full VM.

Differences between LXC and VM

  • Kernel usage: A VM has its own operating system with a dedicated kernel, while an LXC container shares the host’s kernel.
  • Performance: LXC containers have less overhead since they do not require a hypervisor, making them more efficient and allowing direct hardware access.
  • Flexibility: VMs are better suited for applications requiring full system isolation, while LXC containers are ideal for lightweight, fast-starting workloads.
  • Compatibility: Some applications, particularly those requiring specific kernel modules, perform better in a VM than in an LXC container.

Preparing an LXC Container

To install and use Docker inside an LXC container, the “nesting” feature must be enabled in the container options.

Proxmox-Docker-LXC-01

Proxmox-Docker-LXC-01

Proxmox-Docker-LXC-02

Proxmox-Docker-LXC-02

Installing Docker on Ubuntu

System Setup

  • Host System
  • Proxmox 8.3.3
  • CPU: AMD Ryzen 3700x
  • RAM: 80GB
  • SSD: 2x 2TB NVMe
  • Guest System
  • Ubuntu 22.04

Installing Docker in an Ubuntu 22.04 LXC container on Proxmox requires a few steps to ensure smooth operation.

1. Update the System

Start by updating the package lists:

sudo apt-get update

2. Install Required Packages

Install dependencies for package management and certificates:

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

3. Add the Docker Repository

Import Docker’s official GPG key and add the repository:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

4. Update Package Lists Again

Refresh the package lists to recognize the new repository:

sudo apt update

5. Check Available Docker Versions (Optional)

To verify that the correct Docker packages are available:

sudo apt-cache policy docker-ce

6. Install Docker

Now, install Docker:

sudo apt install -y docker-ce

7. Add User to Docker Group

To allow the current user to run Docker without sudo, add them to the docker group.

Log out and back in to apply the group changes.

sudo usermod -aG docker ${USER}

8. Verify Docker Installation

Run the following command to test if Docker is working correctly:

docker run hello-world

TL;DR

sudo apt-get update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update

sudo apt-cache policy docker-ce

sudo apt install -y docker-ce

sudo usermod -aG docker ${USER} # aktuellen benutzer zur Docker Berechtigungsgruppe hinzufügen

Durchschnittliche Bewertung 0 / 5. Bewertungen: 0

Leave a Comment

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

Scroll to Top