Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install docker-compose on Windows

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 ?

like image 313
Chris Avatar asked Mar 26 '15 22:03

Chris


People also ask

Can I use Docker compose on Windows?

Install Docker ComposeIf you installed Docker Desktop/Toolbox for either Windows or Mac, you already have Docker Compose! Play-with-Docker instances already have Docker Compose installed as well. If you are on a Linux machine, you will need to install Docker Compose.

Does Docker desktop include compose?

With Docker Desktop you get Docker Engine, Docker CLI with Compose plugin as well as other components and tools. Check a list of what's shipped with Docker Desktop and a list of key features in the Docker Desktop Overview page. Docker Desktop is available for Mac, Windows, and Linux.


1 Answers

Update 2021: docker-compose has been rewritten in Go, and is now a docker command docker compose

As such, there is no longer the need to "install" it.
See docker compose.


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:

  • cloning https://github.com/docker/compose in /c/Users/<username>/myproject/compose (in order to have persistence, since /c/Users/<username> is automatically mounted, when I use VirtualBox with its extension pack )

  • building the docker-compose image:

      cd /c/Users/<username>/myproject/compose   # that will put the repo in a detached HEAD, but it does not matter here   git checkout 1.2.0   docker build -t docker-compose . 
  • adding a 'dc' alias (in a profile file that I copy to my /home/docker/.ashrc before launching the boot2docker ssh session.)

      dc='docker run --rm -i -t -v /var/run/docker.sock:/var/run/docker.sock -v `pwd`:`pwd` -w `pwd` docker-compose' 

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

like image 180
VonC Avatar answered Oct 08 '22 06:10

VonC