Bobcares

Proxmox Docker Unprivileged Container | A 4-step Method

by | Dec 5, 2022

In this article, we will see how to run Docker inside an unprivileged container in Proxmox. At Bobcares, with our Proxmox Support Services, we can handle your Proxmox issues.

How to run Docker inside an unprivileged container in Proxmox?

The process of running Docker inside an unprivileged container in Proxmox includes the following steps:

  • Configuring Proxmox
  • Making an unprivileged LXC container
  • Installing Docker in LXC
  • Testing Docker

Let’s see each step in detail.

Configuring Proxmox

1. We have to enable the overlay and aufs* in Proxmox. This is done to support Docker-LXC-Nesting.

echo -e "overlay\naufs" >> /etc/modules-load.d/modules.conf

2. In order to verify the modules are active, we have to reboot the Proxmox using the below code:

lsmod | grep -E 'overlay|aufs'

Making an unprivileged LXC container

We can use web UI or shell script to make an unprivileged LXC container. (Follow the Proxmox docs to create an unprivileged LXC container)

1. This LXC container configuration will be kept at:

/etc/pve/lxc/100.conf

2. Add the below code after opening the configuration (To enable these features, we can also use the Proxmox GUI):

features: keyctl=1,nesting=1

 

3. Following that, the 100.conf will look like this:

arch: amd64
cores: 2
features: keyctl=1,nesting=1
hostname: docker
memory: 4096
nameserver: 192.168.40.1
net0: name=eth0,bridge=vmbr1,firewall=1,gw=192.168.40.1,ip=192.168.40.9/24,tag=40,type=veth
ostype: debian
rootfs: storagedocker:100/vm-100-disk-0.raw,size=60G
searchdomain: local.mytld.com
startup: order=1
swap: 4096
unprivileged: 1

Installing Docker in LXC

1. Log into the new LXC container via ssh.

2. Install sudo if needed:

apt install sudo

3. Set the time zone using the code:

dpkg-reconfigure tzdata

4. Now update the other packages:

apt-get update && apt-get upgrade && apt-get dist-upgrade && apt-get autoremove

5. Finally, install Docker. Before copying and pasting, always check the official instructions from the manuals for obsolete code.

sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/debian/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/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

6. Change the storage driver to overlay2.

echo -e '{\n "storage-driver": "overlay2"\n}' >> /etc/docker/daemon.json

7. Adjust Docker subnets

8. Install docker-compose, if desired.

Testing Docker

Restart the LXC container and test the Docker configuration.

systemctl status docker docker run hello-world

Output:

Hello from Docker!

With these steps, we were able to run Docker inside an unprivileged container in Proxmox.

Docker is explicitly encouraged to run inside full VMs rather than unprivileged containers. One of the primary differences is that VMs are fully virtualized, whereas LXC containers merely run all processes on the host machine (the hypervisor). Unprivileged containers employ a combination of app-armor rules and uid-mapping to prevent dangerous access to the host, but if we are conducting important production work or suspect that the Docker tools are unsafe, use a VM rather than LXC.

[Need assistance with another Proxmox query? We’re here to assist.]

Conclusion

The article provides a 4-step method from our Tech team to run Docker inside an unprivileged container in Proxmox.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF