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.
(Update 2017-03-02: but we are getting there. A first series of patches to allow support has been merged in the master branch but is not yet released. However, it does not look like official releases of compose for ARM will be provided in the near future, but at least building them will become even easier.)
(Update 2019-03-24: it is now easily available using pip. Doing pip install docker-compose
works on ARM.)
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 (Update 2017-03-02: soon when the master branch will be merged into the release one, these extra steps won’t be necessary):
$ 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 `dist
` subfolder.
$ 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
Conclusion
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 simply install it using pip install docker-compose
should work.