Docker on Debian 11

Okay, this is more of a reminder to myself just in case I have to set Docker on Debian 11 up again before I find a suitable backup solution.
Update: I found one!

A standard Debian setup is provided; a minimal server with SSH will do.
First, let’s install some pre-requisites:

apt install snmpd snmp wget curl unzip sudo gnupg2 -y

And quickly setup SNMP so we’re able to monitor the VM:

rm  /etc/snmp/snmpd.conf && sudo nano /etc/snmp/snmpd.conf
	agentAddress udp:161,udp6:[::1]:161
	view   all  included   .1
	rocommunity public  default    -V all
	rocommunity6 public  default   -V all
	sysLocation    Berlin
	sysContact     xx@yy.tld

systemctl enable snmpd
systemctl start snmpd

Installing Docker on Debian 11

The original documentation is available at Docker.com, but it’s straightforward and requires a few commands only.

apt install ca-certificates gnupg lsb-release -y

mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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

apt update

apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

And we enable the service to start automatically:

systemctl enable docker.service
systemctl enable containerd.service

Compose should be included for a few releases, but in case it doesn’t work:

DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}

mkdir -p $DOCKER_CONFIG/cli-plugins

curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

That should do! Now let’s install Portainer, too.

Portainer

They have excellent documentation with a step-by-step explanation here.
Essentially, my compose file looks like this:

version: '3.3'
services:
    portainer-ee:
        ports:
            - 8000:8000
            - 9443:9443
        container_name: portainer
        restart: always
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /opt/portainer:/data
        image: portainer/portainer-ee:latest

What you see is that I’m on the Enterprise Edition. You can get it for up to five hosts; that’s very generous. Sign-up is required; go here.

Mounting shares

And of course, the containers require access to network shares, so we need to set them up before deploying other things.
It’s a three-step process, and I need two shares – one for downloads and the other for my media library.
The first step is to create sub-directories:

mkdir /mnt/share
mkdir /mnt/downloads

Step two will mount them:

mount -t cifs -o username=user,password=password //10.0.0.11/share /mnt/share
mount -t cifs -o username=user,password=password //10.0.0.11/downloads /mnt/downloads

And finally, step three makes them permanent:

nano /etc/fstab
	//10.0.0.11/downloads/   /mnt/downloads   cifs   username=user,password=password   0    0
	//10.0.0.11/share/   /mnt/share   cifs   username=user,password=password   0    0

That’s it; we can now jump into Portainer at https://local-ip:9443 and start deploying containers.

Portainer Docker on Debian 11

One more thing: When setting up Portainer, it will use the socket connection to talk to the first host.

It does come with a few limitations, as seen below:

In case you require the features, you can quickly deploy the agent. The documentation is here, but if you prefer a compose file, feel free to use this one:

version: '3.3'
services:
    agent:
        ports:
            - 9001:9001
        container_name: portainer_agent
        restart: always
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - /var/lib/docker/volumes:/var/lib/docker/volumes
        image: 'portainer/agent:2.9.3:latest

Happy containering!
Oh and, in case you struggle with availability, you can follow my series on this topic here.

More homelab content:

1 2 3 4

Leave a Comment

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