Installing Docker on Alpine Linux

Alpine is an excellent lightweight Docker host: ~50 MB base install, ~30 MB RAM at idle, boots in seconds. The trade-off is OpenRC instead of systemd and ash instead of bash. See Alpine Docker gotchas for the sharp edges.

Install

Docker packages live in the community repository, which is disabled by default.

# Enable community repo
sed -i 's|#http://dl-cdn.alpinelinux.org/alpine/v[0-9.]*/community|http://dl-cdn.alpinelinux.org/alpine/v3.21/community|' \
  /etc/apk/repositories

apk update && apk upgrade

# docker-openrc is a PACKAGE (not a command) that provides OpenRC service scripts
apk add docker docker-cli-compose docker-openrc

rc-update add docker default
service docker start

Post-install

# Add user to docker group — no newgrp on Alpine, must log out fully
addgroup $USER docker
exit   # log back in for the change to apply

# Verify
docker --version
docker compose version
docker run --rm hello-world

Daemon configuration

cat > /etc/docker/daemon.json << 'EOF'
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  },
  "storage-driver": "overlay2"
}
EOF

service docker restart

Service management (OpenRC)

Alpine uses OpenRC, not systemd. The equivalents:

systemdOpenRC
systemctl start dockerservice docker start
systemctl stop dockerservice docker stop
systemctl restart dockerservice docker restart
systemctl status dockerservice docker status
systemctl enable dockerrc-update add docker default
systemctl disable dockerrc-update del docker default
systemctl list-unitsrc-update show

IP forwarding (required for overlay networks)

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
rc-update add sysctl

NFS shared storage

apk add nfs-utils
rc-update add rpcbind
rc-update add nfsmount
service rpcbind start

mkdir -p /mnt/nfs/media /mnt/nfs/data

# /etc/fstab — replace <NAS_IP> and share paths with your values
# <NAS_IP>:/exports/media  /mnt/nfs/media  nfs  defaults,_netdev,nofail  0  0
mount -a

Troubleshooting

# Docker won't start
cat /var/log/docker.log
dockerd --debug   # verbose output

# cgroup issues
apk add cgroup-tools
rc-update add cgroups
service cgroups start

# DNS broken in containers
cat > /etc/docker/daemon.json << 'EOF'
{"dns": ["1.1.1.1", "8.8.8.8"]}
EOF
service docker restart

# Overlay network issues — load kernel modules on the host
modprobe ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh

Alpine vs Debian at a glance

MetricAlpineDebian 12
Base install~50 MB~1 GB
RAM at idle~30 MB~150 MB
Boot time~3 sec~15 sec
Package managerapkapt
Init systemOpenRCsystemd
C librarymuslglibc

Use Alpine when resource usage matters most or you’re running a simple, dedicated container host.

Use Debian when you need glibc compatibility, systemd features, or prefer the apt ecosystem.

See also