In this post, I'll explain how to install docker
and docker-compose
on Alpine Linux
Before we begin,
What is Alpine Linux?
Alpine Linux is an independent, non-commercial, general purpose Linux distribution designed for power users who appreciate security, simplicity and resource efficiency
if you are looking for lightweight Linux image to run your docker containers Alpine will be a good choice.
Step 1: Update Alpine 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
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
update the repository by running below command
apk update
After that, we can install docker
and docker-compose
using
apk add docker docker-compose
Step 3: Start & Enable docker service at boot
Enable autostart on boot using
rc-update add docker default
then you can start the docker
service by running below command
/etc/init.d/docker start
Now you have Alpine Linux installed with docker and docker-compose.
Happy Containerize ;)