Running Docker Containers Inside Proxmox LXC: A Step-by-Step Guide
Running Docker Containers Inside Proxmox LXC: A Step-by-Step Guide
Introduction
Proxmox LXC containers offer lightweight virtualization, but running Docker inside an LXC container requires additional configuration. By following this guide, you’ll be able to set up an LXC container in Proxmox and install Docker inside it efficiently.
This approach allows you to run Dockerized applications with minimal overhead compared to full virtual machines (VMs).
Step 1: Creating an LXC Container in Proxmox
- Log into Proxmox Web Interface
-
Open a web browser and go to
https://your-proxmox-ip:8006
-
Log in with your credentials.
- Create a New LXC Container
-
Click on Create CT in the Proxmox interface.
-
Enter a hostname (eg.
docker-lxc
). -
Set a password for the container.
-
Choose an Ubuntu or Debian template from your storage.
- Configure Container Resources
-
Assign at least 2 CPU cores and 2GB RAM.
-
Set storage to at least 10GB for Docker images and containers.
- Network Setup
-
Assign a static IP or use DHCP.
-
Ensure the container has internet access.
- Finish and Start the Container
-
Click Finish to create the container.
-
Start the container and open a console session.
Step 2: Preparing the LXC Container for Docker
By default, LXC containers in Proxmox have restrictions that prevent Docker from working properly. We need to modify some settings.
- Edit the Container Configuration File
-
On the Proxmox host, open the LXC config file:
sudo nano /etc/pve/lxc/.conf
-
Add the following lines to enable Docker compatibility:
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: (remove this line if present)
-
Save and close the file.
- Restart the Container
-
Run:
pct stop && pct start
Step 3: Installing Docker Inside the LXC Container
- Update and Install Required Packages
-
Run the following commands inside the container:
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl gnupg2 software-properties-common
- Add Docker Repository and Install Docker
-
Run:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
- Verify Docker Installation
-
Check if Docker is running:
sudo systemctl status docker
-
Run a test container:
sudo docker run hello-world
Step 4: Enabling Docker at Startup
To ensure Docker runs on every reboot:
-
Run:
sudo systemctl enable docker
-
Restart the container and verify Docker starts automatically.
Conclusion
You’ve successfully set up Docker inside a Proxmox LXC container. This setup provides an efficient way to run containerized applications without the overhead of full VMs.