6.1 KiB
description | keywords | title |
---|---|---|
How to install Docker Compose | compose, orchestration, install, installation, docker, documentation | Install Docker Compose |
You can run Compose on macOS, Windows and 64-bit Linux. To install it, you'll need to install Docker first.
To install Compose, do the following:
-
Install Docker Engine:
-
Mac installation{: target="blank" class=""}
-
Windows installation{: target="blank" class=""}
-
Ubuntu installation{: target="blank" class=""}
-
Other systems{: target="blank" class=""}
-
-
Docker for Mac, Docker for Windows, and Docker Toolbox include Docker Compose, so most Mac and Windows users do not need to install Docker Compose separately.
If you are running the Docker daemon and client directly on Microsoft Windows Server 2016 (with Docker EE for Windows Server 2016), you do need to install Docker Compose.
To do this, start an "elevated" PowerShell (run it as administrator). Search for PowerShell, right-click, and choose Run as administrator. When asked if you want to allow this app to make changes to your device, click Yes.
Run the following command to download Docker Compose, replacing
$dockerComposeVersion
with the specific version of Compose you want to use:Invoke-WebRequest "https://github.com/docker/compose/releases/download/$dockerComposeVersion/docker-compose-Windows-x86_64.exe" -UseBasicParsing -OutFile $Env:ProgramFiles\docker\docker-compose.exe
For example, to download Compose version 1.12.0, the command is:
Invoke-WebRequest "https://github.com/docker/compose/releases/download/1.12.0/docker-compose-Windows-x86_64.exe" -UseBasicParsing -OutFile $Env:ProgramFiles\docker\docker-compose.exe ``` Now, run the executable to install Compose.
-
On Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub{: target="blank" class=""}. Follow the instructions from the link, which involve running the
curl
command in your terminal to download the binaries.Note: If you get a "Permission denied" error, your
/usr/local/bin
directory probably isn't writable and you'll need to install Compose as the superuser. Runsudo -i
, then the two commands below, thenexit
.The following is an example command illustrating the format:
curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
If you have problems installing with
curl
, see Alternative Install Options. -
Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
-
Optionally, install command completion for the
bash
andzsh
shell. -
Test the installation.
$ docker-compose --version docker-compose version 1.12.0, build b31ff33
Alternative install options
Install using pip
Compose can be installed from pypi
using pip
. If you install using pip
, we recommend that you use a
virtualenv because many operating systems
have python system packages that conflict with docker-compose dependencies. See
the virtualenv tutorial
to get started.
pip install docker-compose
if you are not using virtualenv,
sudo pip install docker-compose
Note: pip version 6.0 or greater is required.
Install as a container
Compose can also be run inside a container, from a small bash script wrapper. To install compose as a container run:
$ curl -L --fail https://github.com/docker/compose/releases/download/1.12.0/run.sh > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
Master builds
If you're interested in trying out a pre-release build you can download a binary from https://dl.bintray.com/docker-compose/master/. Pre-release builds allow you to try out new features before they are released, but may be less stable.
Upgrading
If you're upgrading from Compose 1.2 or earlier, you'll need to remove or migrate your existing containers after upgrading Compose. This is because, as of version 1.3, Compose uses Docker labels to keep track of containers, and so they need to be recreated with labels added.
If Compose detects containers that were created without labels, it will refuse to run so that you don't end up with two sets of them. If you want to keep using your existing containers (for example, because they have data volumes you want to preserve) you can use compose 1.5.x to migrate them with the following command:
docker-compose migrate-to-labels
Alternatively, if you're not worried about keeping them, you can remove them. Compose will just create new ones.
docker rm -f -v myapp_web_1 myapp_db_1 ...
Uninstallation
To uninstall Docker Compose if you installed using curl
:
sudo rm /usr/local/bin/docker-compose
To uninstall Docker Compose if you installed using pip
:
pip uninstall docker-compose
Note: If you get a "Permission denied" error using either of the above methods, you probably do not have the proper permissions to remove
docker-compose
. To force the removal, prependsudo
to either of the abovecommands and run again.