I really like docker-compose, it has a simple language (YaML) to describe how to build and run a container, so you do not have to remember (or count on your history availability) the long `
docker build ...` and `
docker run ...` commands (and many others).
However, docker-compose is not (yet) available for Raspberry Pi or any other ARM architecture.
Our Hypriot friends have done a great job and do provide a binary version of it on their repositories. But I usually do not like to add 3rd party repositories and I finded the list of changes (patches) longer than I expected.
So I forked the official Docker Compose repository and did a few minimalistic changes in order to get a built of docker-compose for Raspberry Pi. I have created a Pull Request in the hope that it might get accepted and that ARMv7 be officially built. But while waiting for the review process to be triggered, here is how to do it for yourself.
Download the Project
As pre-requisite you need to have `git` (
sudo apt-get install git) and `docker` (see my previous article) already installed on your platform.
Then get a copy of the project on your local Raspberry Pi.
$ git clone https://github.com/docker/compose.git $ git checkout release
Now apply the following patch:
$ cd compose $ cp -i Dockerfile Dockerfile.armhf $ sed -i -e 's/^FROM debian\:/FROM armhf\/debian:/' Dockerfile.armhf $ sed -i -e 's/x86_64/armel/g' Dockerfile.armhf
Build and install docker-compose
To build the docker-compose binary, the procedure is rather simple. First you need to build the docker image which will be used to set-up the build environment. Second and last you need to run the container which will build docker-compose. At the end the binary will be available under the `
$ docker build -t docker-compose:armhf -f Dockerfile.armhf . $ docker run --rm --entrypoint="script/build/linux-entrypoint" -v $(pwd)/dist:/code/dist -v $(pwd)/.git:/code/.git "docker-compose:armhf"
After several minutes you will get a binary file which you can then install on your system:
$ ls -l dist/ total 6816 -rwxr-xr-x 1 pi pi 6976500 Feb 8 11:41 docker-compose-Linux-armv7l $ sudo cp dist/docker-compose-Linux-armv7l /usr/local/bin/docker-compose $ sudo chown root:root /usr/local/bin/docker-compose $ sudo chmod 0755 /usr/local/bin/docker-compose $ docker-compose version docker-compose version 1.11.0-rc1, build daed6db docker-py version: 2.0.2 CPython version: 2.7.13 OpenSSL version: OpenSSL 1.0.1t 3 May 2016
Goodies: Install docker-compose bash autocompletion
Docker Compose provides autocompletion for bash. Installing it is as simple as doing:
$ sudo curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
If you might wonder why I stated “the easy way” in my title, well if you want to master Docker, you ought to consider the above easy
Of course in our field of work nothing is as simple as a mouse click, especially when you need to create something that is not (until today) provided out of the box. If you want real easy and are using a Debian-based Linux OS, then just use the repository provided by Hypriot. If you’re not using Debian, you might want to consider the above described approach.