Docker + Dockge on a Alpine VM
Make it small, use Alpine images. The smallest of them all is probably Alpine. I also included notes on Dockge and Portainer. For most of my VM apps Alpine is more than enough. It's small because it's lacking the bloat from GNU.
Install Alpine – 3.15 and newer
Current Alpine Version 3.21.3 (Released Feb 13, 2025)
Download the correct image to your storage, ISO or Template.
Then, set up your VM or CT. Start and login as root, no password. Follow the on-screen info and my notes below.
Adding the community repo
If you need things like the QEMU-Guest-Agent or sudo, you need to activate the community repo. Edit the file /etc/apk/repositories
and remove the #
in front of the …/community
lines.
Adding QEMU-Guest-Agent service
Use doas
or sudo
if not running as root.
- Add the package:
apk add qemu-guest-agent
- Start the service:
rc-service qemu-guest-agent start
- Enable the service on startup:
rc-update add qemu-guest-agent
- Restart the service:
rc-service qemu-guest-agent restart
Adding a disk
Format a disk: e.g., by fdisk /dev/sdb
add a partition by hitting n
and p
1
and enter
to the rest, then hit w
to write to the disk.
Create a file system on the new disk mkfs.ext4 /dev/sdb1
and doas reboot
.
Add a disk to fstab. Find the UUID by blkid
and vi/nano etc/fstab
, add it as UUID=<UUID> /srv ext4 defaults 0 2
. Change /srv
to something and the 2
means it's required.
Expanding a disk. First expand the allocated disk in your VM and then SSH in to the VM and do.
- First
sudo growpart /dev/sdb 1 --update auto
- and then
sudo resize2fs /dev/sdb1
- Use
df -h
to check for success
Install Docker
Docker packages are in the community repo
- Install Docker-ce:
apk add docker
- Add a user to the docker group:
addgroup username docker
- Start at boot:
rc-update add docker default
andservice docker start
- Docker compose:
apk add docker-cli-compose
Docker rootless allows unprivileged users to run the docker daemon and docker containers in user namespaces.
apk add docker-rootless-extras
andrc-update add cgroups
- see the Docker documentation for the rest
- You might encounter this message when executing
docker info
.
To correct this situation, you must configurecgroups
properly. - Create your external networks, one for external and one for internal traffic.
docker network create -d bridge <external name>
docker network create -d bridge <internal name>
- Make the generic folders you need for your stacks
Install Dockge
Dockge is my favorite, but there is thing you benefit from also having Portainer.
Create directories
Create directories that store your stacks and store Dockge's stack
mkdir -p /opt/stacks /opt/dockge
cd /opt/dockge
Download your compose.yaml
curl "https://dockge.kuma.pet/compose.yaml?port=5001&stacksPath=%2Fopt%2Fstacks" --output compose.yaml
services:
dockge:
image: louislam/dockge:1
restart: unless-stopped
ports:
- 5001:5001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/app/data
# Stacks Directory
# ⚠️ READ IT CAREFULLY. If you did it wrong, your data could end up writing into a WRONG PATH.
# ⚠️ 1. FULL path only. No relative path (MUST)
# ⚠️ 2. Left Stacks Path === Right Stacks Path (MUST)
- /opt/stacks:/opt/stacks
environment:
# Tell Dockge where to find the stacks
- DOCKGE_STACKS_DIR=/opt/stacks
Start the Server
Docker Compose V2
docker compose up -d
Podman
docker-compose up -d
Alternative, use docker run
doas docker run -d -p 5001:5001 --name Dockge --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v /home/$USER/docker/dockge/data:/app/data -v /home/$USER/docker/stacks:/home/$USER/docker/stacks -e DOCKGE_STACKS_DIR=/home/$USER/docker/stacks louislam/dockge:latest
Portainer
First, create the volume that Portainer Server will use to store its database:
docker volume create portainer_data
Then, download and install the Portainer Server container:
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
HTTP port 9000
open for legacy reasons, add : -p 9000:9000
to your docker run
command
Point your browser to https://<ServerIP>:9443
and create your admin user.
Portainer stores the docker-compose files at /var/lib/docker/volumes/portainer_data/_data/compose/
References
Alpine [1] Docker [2] Dockge [3] Portainer [4]
Docker homepage, getting started GitHub, official install Ubuntu, Documentation ↩︎
Dockge is a fancy, easy-to-use and readtive self-hosted docker compose.yml stack-oriented manager. GitHub
Note from the author: "Dockge" is a coinage word which is created by myself. I originally hoped it sounds like Dodge , but apparently many people called it Dockage, it is also acceptable. The naming idea came from Twitch emotes like sadge, bedge or wokege. ↩︎Portainer is a self-hosted software that simplifies the deployment, monitoring, and security of Docker, Swarm, Kubernetes and Podman clusters. It supports multi-cluster and multi-device management, centralized access and authorization, and customizable policies and quotas. homepage ↩︎