Compiling the docker-compose binary for Raspberry Pi
Update on 2021-05-21:
Although the method presented in this post still works as described for the version mentioned (1.25.5), for newer versions (e.g.: 1.29.2) changes in the cloned repo code are required.
Because of that it is recommended to install
docker-compose
on a Raspberry Pi using the pip alternative method.
Original post from 2020-06-05:
Everyone knows the hassles of installing docker on a Raspberry Pi are mostly gone.
Besides specialized distros like dietpi - where the installation is one command-line away - or hypriot -, which comes with it preinstallled and optimized, the official documentation already includes instructions for using an official arm
supported repository.
If you consider:
But trying to install docker-compose using the official instructions…
You’ll see it returns an error. Maybe not, since the command fails without any visible error:
The download was only 9kb, it was not the expected binary, but the 404 Not Found
error returned when accessing https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-armv7l. There are no release builds for arm
architecture.
It’s possible to install docker-compose
using pip, but what if a pre-compiled binary is desired?
Compiling
It’s actually pretty simple to compile the docker-compose
binary. The only requirement is a Raspberry Pi with a working docker
installation.
To build and install the 1.25.5 release:
# clone the repo
$ git clone https://github.com/docker/compose.git
$ cd compose
# checkout the desired version
$ git checkout 1.25.5
# run the build script
$ ./script/build/linux
# wait a little while... and install it
$ sudo mv dist/docker-compose-Linux-armv7l /usr/local/bin/docker-compose
The build script detects the host architecture and compile the binary using the correct docker images, armhf
on the Raspberry Pi 3 Model B+.
That’s it! plain and simple! and don’t forget to save it aside so it’s easy to reuse it on other boards… because who only has one rPi? I know I don’t…