How to install docker-compose on Windows

Chris picture Chris · Mar 26, 2015 · Viewed 64.8k times · Source

If I type the following commands in boot2docker as shown on the docker website:

curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

When I type the following commands to check if the installation was successful, I get:

/usr/local/bin/docker-compose: line 1: syntax error: unexpected newline

So, how can I install docker-compose on boot2docker ?

Answer

VonC picture VonC · Apr 19, 2015

Update 7th of november 2018:

On desktop systems like Docker for Mac and Windows, Docker Compose is included as part of those desktop installs.

Accordingly to the documentation, Docker for Windows and Docker Toolbox already include Compose along with other Docker apps, so most Windows users do not need to install Compose separately.


Update 2017: this is now officially managed (for Windows 10 supporting Hyper-V) with "Docker for Windows".
See "Install Docker for Windows".
It does have a chocolatey installation package for Docker, so:

choco install docker-for-windows 
# or
choco upgrade docker-for-windows 

Again, this requires a 64bit Windows 10 Pro, Enterprise and Education (1511 November update, Build 10586 or later) and Microsoft Hyper-V.

For other Windows, you still need VirtualBox + Boot2Docker.


Update: docker compose 1.5 (Nov 2015) should make it officially available for Windows (since RC2).

Pull requests like PR 2230 and PR 2143 helped.
Commit 13d5efc details the official Build process for the Windows binary.


Original answer (Q1-Q3 2015).

Warning: the original answer ("docker-compose in a container") below seems to have a bug, according to Ed Morley (edmorley).

There appear to be caching issues with the "docker-compose in a container" method (See issue #6: "Changes to docker-compose.yml and Dockerfile not being detected")

Ed recommends:

As such for now, running the Python docker-compose package inside boot2docker seems to be the most reliable solution for Windows users (having spent many hours trying to battle with the alternatives).

To install docker-compose from PyPI, run this from inside boot2docker:

docker@boot2docker:~$ 
tce-load -wi python && curl https://bootstrap.pypa.io/get-pip.py | \
  sudo python - && sudo pip install -U docker-compose

To save having to run the above every time the boot2docker VM is restarted (since changes don't persist), you can use bootlocal.sh like so:

docker@boot2docker:~$ 
echo 'su docker -c "tce-load -wi python" && \
  curl https://bootstrap.pypa.io/get-pip.py | \
  python - && pip install -U docker-compose' | \ 
  sudo tee /var/lib/boot2docker/bootlocal.sh > /dev/null && \
  sudo chmod +x /var/lib/boot2docker/bootlocal.sh

(The su docker -c gymnastics are required since tce-load cannot be run as root, and bootlocal.sh is run as root. The chmod of bootlocal.sh should be unnecessary once #915 is fixed.
Add -a to the tee command if you need to append, rather than overwrite bootlocal.sh.)

If you wish to use a pre-release version of docker-compose, then replace pip install -U docker-compose with pip install -U docker-compose>=1.3.0rc1 or equivalent.


Original answer:

I also run docker-compose (on Windows boot2docker) in a image by:

From there, a 'dc up' or 'dc ps' just works. On Windows. With boot2docker 1.6.