Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #74: curl vs pip for Installing Docker Compose


On Linux, Docker Compose doesn't come bundled up with Docker like it does on Docker for Windows / Mac. So which one should you use?

When it comes to installing Docker Compose on Linux you have 2 options:

  1. You can install Docker Compose on Linux by downloading the self-contained binary file from GitHub. This is typically done with curl. For example, check the install guide on the GitHub releases page.

  2. Install it using PIP by running pip3 install docker-compose. Whether or not you choose to use --user or put it into a virtual environment is up to you.

In both cases, you’re still running a Python application in the end.

I used to always download the self-contained file because it felt easier to me to download a single file, make it executable and run it but not anymore.

Lately I’ve been using the PIP version in development and production for 3 reasons:
  1. The self-contained binary is using PyInstaller and every time you run a Docker Compose command it’s dumping a bunch of files to a temp directory to run the Python app inside. This consistently adds ~200ms* of delay to any command.

    *I tested this on WSL running Ubuntu 18.04 and on a real Ubuntu 18.04 server. It was always about a 200ms difference. On my machine it was 170ms (PIP) vs 370ms (binary) to run time docker-compose --version.

  2. When it comes to automating the installation of Docker Compose , PIP is much easier to use because you can choose to download the latest version, or pin a specific version but with curl you always need to reference a version number in the download URL.

  3. If you use any of Ansible’s docker_* modules, they depend on having the docker and / or docker-compose PIP packages installed, and using PIP for Docker Compose gets you half of the way there already.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.