How to install docker & docker-compose on Alpine Linux

In this post, we’ll show how to install docker-compose (and the docker backend) on Alpine Linux.

Step 1: Enable the apk community repository

Edit the repository config as root using

vi /etc/apk/repositories

It should look like this (the exact URLs will vary according to your selected mirror)

#/media/cdrom/apks
http://ftp.halifax.rwth-aachen.de/alpine/v3.13/main
#http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/main
#http://ftp.halifax.rwth-aachen.de/alpine/edge/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/testing

Now find the **line that ends in /community**and **does NOT end with /edge/community.**Typically, this is the second linein the file:

#http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community

Navigate to this line by using the *arrow keys,*press the Insert key in order to activate Editing.

Then remove the # at the beginning of the line. The resulting file should look like this:

#/media/cdrom/apks
http://ftp.halifax.rwth-aachen.de/alpine/v3.13/main
http://ftp.halifax.rwth-aachen.de/alpine/v3.13/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/main
#http://ftp.halifax.rwth-aachen.de/alpine/edge/community
#http://ftp.halifax.rwth-aachen.de/alpine/edge/testing

Now save the file an exit the editor by pressing the Esc key, entering :wq and pressing enter.

Step 2: Install docker & docker-compose

Now we’ll fetch the package lists using

apk update

After that, we can install docker and docker-compose using

apk add docker docker-compose

Step 3: Enable docker daemon autostart & start docker daemon

Enable autostart on boot using

rc-update add docker default

and then start docker using

/etc/init.d/docker start