Alpine Linux Docker Host

Alpine Linux Docker Host
Photo by JOHN TOWNER / Unsplash

Using Alpine Linux as a lightweight Docker host

First thing is to grab the .iso from the Alpine Linux Website, but depending on what hypervisor you are going to run your Docker hosts on, whether it be;

Bare-metal/Xen/VMWare/KVM/Proxmox then you can choose either standard or virtual. You will want to also select a x86_64 image for amd/intel host.

The first step is to setup alpine;


Complete the setup stage, configure the server and then reboot.


Next we need to set up ssh access, so in the root terminal;

vi /etc/ssh/sshd_config

uncomment the following flags;

#port 22
#allowrootlogin yes
#allow publickey auth

port 22
allowrootlogin yes
allow publickey auth

Then restart the ssh service

service sshd restart

Next we enable the community source repos for Alpine;

vi /etc/apk/repositories

uncomment the community repo


Update and upgrade all packages

apk update && apk upgrade --available

Install all the required programs

apk add --no-cache bash btrfs-progs docker git e2fsprogs e2fsprogs-extra htop iptables nfs-utils py-pip sudo xfsprogs xz

Make sure Docker starts on boot

rc-update add docker boot

Next is to install docker compose and for this we use pip

pip install docker-compose

Once Docker is installed we continue to add our user

addgroup dominic

adduser -s /bin/ash -G dominic dominic

Add our user to the sudo group to allow us some root access

sed -ri 's/(wheel:x:10:root)/\1,dominictaylor/' /etc/group
sed -ri 's/# %wheel\tALL=\(ALL\) ALL/%wheel\tALL=\(ALL\) ALL/' /etc/sudoers


uncomment %wheel ALL=(ALL) ALL

Add our user to the Docker group

addgroup dominictaylor docker

Re-secure ssh and disallow root access now we have a user

sudo vi /etc/ssh/sshd_config

comment out permitrootlogin like #permitrootlogin
sudo service sshd restart

Finally we should have a running Docker host on Alpine Linux

ssh [email protected]

docker ps -a

docker run .....