Enterprise grade Java.
You'll read about Conferences, Java User Groups, Java, Integration, Reactive, Microservices and other technologies.

Monday, June 8, 2015

Docker Compose on Windows with Python And Babon

14:30 Monday, June 8, 2015 Posted by Markus Eisele
, , ,
Compose is a tool for defining and running complex applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running. It is the only tool in the Docker tool-chain, which doesn't have a native binary for Windows in place right now and to get it up and running on Windows requires quite some work.

Using Babon and Python
The official compose documentation implies, that there is a python only way on not supported platforms. As a matter of fact, this is not totally true. Even the Python package relies on POSIX based commands which aren't available on Windows. If you try to go down this road you will get surprisingly far, but will not finish. The only way to make it work is to use CygWin. For those of you, who don't like it (like I don't), there is a decent alternative called Babun. Babun is a turn-key CygWin distribution for developers and is very easy to install and maintain.
  • Download the installer ZIP archive from the Babun homepage. (~280MB)
  • Unzip the archive to a temporary folder.
  • Change to the unzipped folder and start the install.bat (this might take a while) When you're finished, you can safely delete the temp folder.
  • The babun shell is now open, run the command: "babun update"
  • Change the default shell from zsh to bash if you prefer that by running the command: "babun shell /bin/bash".
  • Edit ~/.bashrc to activate loading of ~/.bash_aliases. (scroll down a bit until you find the line: "#Aliases" and un-comment the if statement.
  • Install additional Python essentials:
    pact install python-setuptools 
    pact install libxml2-devel libxslt-devel libyaml-devel
    curl -skS https://bootstrap.pypa.io/get-pip.py | python
    pip install virtualenv
    curl -skS https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python
This installed a bunch of python packages and the pipsi package manager to your Babun installation. Now you're ready to actually install the docker compose python package:
pip install -U docker-compose
After everything got downloaded and installed, you can now use compose from Babun:
{ ~ }  » docker-compose --version                                                            
docker-compose 1.2.0
With the mapped directories it is easy to change to a temp folder on your windows drive (e.g. /d/temp/) and use compose. Make sure you have everything you need in your PATH variable (Hint: that is different now, e.g. just use:  PATH=$PATH\:/d/path/to/docker/exe ; export PATH ) and make sure to set your environment properly:
eval "$(docker-machine env)"
Now, you can go ahead and just use a very simple docker-compose.yml file, like the one Arun blogged about and you have a bunch of instances up and running without any further configuration or command line hacks.
Find the complete reference to the compose file format on the official Docker Website.

Using the Docker Image Workaround
If you want to, you can try to use the (unofficial) Docker Compose image and run it as a container locally. While this seems to be a solution, I couldn't get this to work on plain Windows. Any pointer and ideas appreciated.

A Two Minute Babun Screencast
Have a look at a 2 minutes long screencast about Babon by @tombujok.