How to install docker on Alpine Linux VM

How to install docker on Alpine Linux VM

15th March 2019 3 By George Wou
5 min read


Alpine linux is a lighweight linux distro, making it small, fast and ideal for VM’s when server resources are limited. Especially when talking about running docker containers, a VM is the only way to go since LXC containers are not supported and its hacky to make docker run inside an LXC.

The Docker containers can be administered through the command line or by using a GUI tool.The two most lightweight administration tools are:

  • Cockpit, it can run only in systemd distros so it is not an option for Alpine.
  • Portainer, comes as a docker container, ideal for Alpine.

Following are the steps required to configure an Alpine system and install Docker.


Create Alpine VM on Proxmox

Download the latest .iso from Virtual category in .

Upload it to Proxmox VE from gui and create VM.

how to install docker on alpine

Typical example settings with one network card on Intel Core2 quad core PC

Configuration Tabs:

    • OS -> Other OS types
    • CD/DVD -> Use disk image (iso)
    • Hard Disk -> Bus/Device IDE 0 , Storage local-lvm, Cache Default (no cache)
    • CPU -> Type Default(kvm64)
    • Memory -> Auto allocate and input the desired range
    • Network -> Bridged mode , Model VirtIO (paravirtualized)

Again these are suggested defaults and depend on the machine and the network plan we have in mind.


Initial Setup

Still in Proxmox GUI , go to the new VM’s console, login as root and type:


and answer the questions of the wizard,including changing the root password.Alpine setup is possibly the easiest linux setup.Defaults are fine except in the disk creation.After selecting disk (sda) and purpose (sys), at least for this simple use case, type (y) in the warning:erase the above disk and continue ? question.

Alpine will prepare the portion of the hard disk allocated to our VM and will ask to reboot.

After rebooting the vm, from the proxmox console of the Alpine VM create a group and a user so we can ssh to the vm remotely from the terminal of our choice and not be bound to the builtin console of the proxmox GUI anymore:

addgroup -g 150 docker
adduser -G docker dockeras
cat /etc/passwd

We use docker group name on purpose because it will be needed later.

Now add the user in sudoers file to be able to execute all commands:

apk add sudo

add anywhere this line:

dockeras ALL=(ALL) ALL

Now press ESC and :wq to save and exit the editor. :q! to exit without saving.

Note:If for any reason we need to ssh as root,from proxmox GUI console:

vi /etc/ssh/sshd_config

and replace #permitrootlogin no with permitrootlogin yes .Save and exit the editor.Then restart ssh service:

service sshd restart

Now we can leave the proxmox console and ssh to the server from another machine:

ssh [email protected]

Install qemu-guest-agent [optional]

Finally install a qemu agent so the Alpine VM can properly shutdown when initiated by the Proxmox VE host e.g for scheduled backups :
First enable the agent from the proxmox GUI : Go to Alpine VM  id->Options->Qemu Agent->yes.
Then from the VM cli do:
wait for reboot, reenter the VM and do:
sudo apk add qemu-guest-agent
Now if you go to the dev/ directory there should be a new virtual port file called vport1p1.
Edit the qemu agent’s initialization script:
nano /etc/init.d/qemu-guest-agent
Replace the last line with this one:
command_args="-m ${GA_METHOD:-virtio-serial} -p ${GA_PATH:-/dev/vport1p1} -l /var/log/qemu-ga.log -d"
Make the agent start at boot:
rc-update add qemu-guest-agent boot
Shutdown the VM, start again and you are ready!



Install Docker Engine

 We need to add the community repository in alpine that contains docker:

vi /etc/apk/repositories
add this line:

Now update the repositories, check that docker is present in apk and install:

sudo apk update
apk policy docker
sudo apk add docker

make docker always start on Alpine boot:

sudo rc-update add docker boot
Start the docker service and check its status:
sudo service docker start
service docker status
Test that docker can actually download docker images:
docker run --rm hello-world
If it gives a similar error:
docker: error pulling image configuration: Get
NFht7gXEfkAMCoGqc%3D: dial tcp: lookup on read udp> i/o timeout.
it means it can not contact the docker registry, caused by misconfiguration of the local network dns and we need to specify another dns manually , like google’s. Setup can only be changed as root:
press enter on the domain name question and on the second.
If the test is succesfull Docker on our Alpine linux virtual machine is ready and operational!



In this article we described the proccess of creating an Alpine VM, OS preparation , creation of a group and a user to operate our dockers, installation of the Docker daemon and a solution for a common error .

For docker administration consult the follow up article How to install Sonarr Radarr and Jackett with Docker.


Part 2:How to install Sonarr Radarr and Jackett with Docker

Part 3:How to install Sonarr Radarr and Jackett with Docker-Compose