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.
Log in as root, no password, and issue setup-alpine to create the VM.
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 vi /etc/apk/repositories and remove the # in front of the …/community lines, :wq to save.
Adding QEMU-Guest-Agent service
Use doas or install and use sudo – if you're not running as root.
- Add stuff needed:
apk add curlorapk add curl wget nano sudo - 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
- Start the service:
Adding a disk for the containers
Use doas or install and use sudo – if you're not running as root.
Format a disk:
Format the new disk e.g., by fdisk /dev/sdb add a partition by hitting n and p 1 and enter to First and Last sector, then hit w to write it all to the disk.
Create a file system
Create a file system on the new disk mkfs.ext4 /dev/sdb1 and reboot now.
Add a disk to fstab.
Change /opt to something (/srv ) and the 2 means it's required.
- Find the UUID by
blkidandvi/nano etc/fstab, - add it as
UUID=<UUID> /opt ext4 defaults 0 2.
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 -hto 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 defaultandservice 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-extrasandrc-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 configurecgroupsproperly. - 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.
Use doas or install and use sudo – if you're not running as root.
Create directories
Create directories that store your stacks and store Dockge's stack
doas mkdir -p /opt/stacks /opt/dockge && cd /opt/dockgeDownload your compose.yaml
doas 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/stacksStart the Server
Docker Compose V2
docker compose up -dPodman
docker-compose up -dAlternative, 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:latestPortainer
First, create the volume that Portainer Server will use to store its database:
docker volume create portainer_dataThen, 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:latestHTTP 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 ↩︎