How To Install Docker Compose: A Simple Guide
In this guide, learn how to install Docker Compose to make it easy to create a container-based architecture.
Docker helps you build, deploy, and run containerized applications. These containers usually include the libraries, environment variables, dependencies, and files required by an app to run. Docker provides tools such as Docker Engine and Docker CLI for managing applications in isolated environments.
Docker Compose is open-source software for building and running multi-container Docker applications. With Docker Compose, you need to declare your app’s services and configurations in a YAML file before running it. This configuration file is also commonly referred to as docker-compose.yml.
In summary, Docker Compose enables you to define, run, and stop Docker services. You can also view which services are running in the background—as well as print output logs.
This article provides a step-by-step tutorial on how to install Docker Compose on macOS, Microsoft Windows, and Linux operating systems.
Installation requirements
Let’s walk through the prerequisites for installing Docker Compose in the Linux, Microsoft Windows, and macOS operating systems.
Linux
To install Docker Compose on Linux, your PC should meet the following minimum requirements:
- 64-bit kernel
- KVM virtualization support
- 4 GB of RAM
- Systemd init system
- QEMU version 5.2 or higher
- Docker installed
You can check if you meet the above requirements by running the following commands on your terminal:
--CODE language-markup--
sudo lscpu
--CODE language-markup--
sudo lshw
--CODE language-markup--
hwinfor
Windows
The minimum requirements for installing Docker Compose on Windows include:
- Windows 10 or higher
- 4GB of RAM
- A 64-bit processor
- BIOS-enabled hardware virtualization
macOS
To install Docker Compose on macOS, users need to satisfy the following minimum requirements:
- macOS version 10.15 or higher
- 4GB of RAM
VirtualBox earlier than version 4.3.30 is incompatible with Docker Desktop, and should be uninstalled.
You can uninstall incompatible or previous VirtualBox versions using the VirtualBox_Uninstall.tool file included in the latest software package.
Once you have downloaded the latest VirtualBox installer, mount it as a disc image and then open the mounted file in Finder. You will see the VirtualBox_Uninstall.tool among other files in the folder.
Double-click on the VirtualBox_Uninstall.tool and confirm that you wish to uninstall your VirtualBox version.
How to install Docker Compose
Now that you know the requirements, let’s review the steps for installing Docker Compose on Linux, Windows, and macOS.
Linux
Linux users should follow the steps below to install Docker Compose.
Step one: Install Docker.
To run Docker Compose on Linux, you need to have Docker installed. You can check if Docker is installed by running the following command in your terminal.
--CODE language-markup--
docker run hello:world:latest
In case you have Docker installed, you should see a Hello from Docker message on the terminal.
If you see an error message, it means that Docker is not installed. You can install the latest Docker version from the Docker repository as follows:
Update the apt library and install the necessary packages using the Docker commands below.
Update the apt library:
--CODE language-markup--
sudo apt-get update
Install the required packages:
--CODE language-markup--
sudo apt-get install \ca-certificates \curl \gnupg \lsb-release
Add the official GPG key from Docker:
--CODE language-markup--
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Set up the Docker hub or repository using the following command:
--CODE language-markup--
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install the latest version of the Docker Engine:
--CODE language-markup--
sudo apt-get install containerd.io docker-ce-cli docker-ce
Alternatively, you can download your preferred version of Docker Engine by specifying the version number in the command (Replace VERSION_STRING with your version number), as shown below:
--CODE language-markup--
sudo apt-get install containerd.io docker-ce-cli= < VERSION_STRING > docker-ce= < VERSION_STRING >
We can now test if Docker Engine was installed correctly by running:
--CODE language-markup--
sudo docker run hello-world
You can proceed to the next step if you see a Hello from Docker output on the command line.
Step two: Download and install Docker Compose.
In Linux, Docker Compose is usually distributed as a separate binary. However, there are some Linux distributions already using Docker Compose in their package managers.
Docker Compose can be installed on Linux in the following ways:
The first technique is a manual installation. In this step, we first confirm the latest version from the official Docker GitHub repo. As of this writing, the latest Docker Compose version is 2.9.0.
We then download and install this version from the release page using the following Compose commands.
Specifying that we wish to install Docker Compose in the $HOME directory:
--CODE language-markup--
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
Creating a cli-plugins directory which will contain our Docker Compose files:
--CODE language-markup--
mkdir -p $DOCKER_CONFIG/cli-plugins
Downloading Docker Compose CLI version 2.9.0 from the official repo:
--CODE language-markup--
curl -SL https://github.com/docker/compose/releases/download/v2.9.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
Note: To allow other users to access the Docker Compose installation, replace:
--CODE language-markup--
/.docker/cli-plugins
With:
--CODE language-markup--
/usr/local/lib/docker/cli-plugins
Remember to add the necessary executable permissions to run the Docker Compose binary. Executable permissions allow the user to run or execute different files.
You can enable executable permissions in Linux using this command:
--CODE language-markup--
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
If you have installed Docker Compose for all users, execute this command to apply executable permissions:
--CODE language-markup--
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
The second method involves installing Docker Compose from the repository directory. In this technique, we use the commands below to download and install the Docker CLI Compose plugin automatically.
Update the apt package index:
--CODE language-markup--
sudo apt-get update
Installing the docker-compose-plugin:
--CODE language-markup--
sudo apt-get install docker-compose-plugin
Step three: Test the Docker Compose installation.
To test whether or not the Docker Compose plugin was installed successfully, run the following command in the terminal as a root user.
--CODE language-markup--
$ docker compose version
You should see a Docker Compose version v.2.9.0 message. Note that the version may change depending on when you installed the plugin.
Windows
For Windows, Docker Compose is included as a plugin in Docker Desktop. Other tools included in Docker Desktop are Docker CLI and Docker Engine. We will outline the steps for installing Docker Desktop on Windows.
Step one: Download the Docker Desktop installer.
The Docker Desktop installer can be downloaded from the official Docker website. When you navigate to the website, you will see the following page:
Click on the blue button to download the Docker Desktop installer. When the download is complete, the installer will be stored in your preset folder (usually the downloads directory).
Step two: Install Docker Desktop
Navigate to the downloads folders and search for a file named Docker Desktop installer.exe. Double click on this file to launch the installation wizard. A security window will pop up asking whether you wish to continue with the installation. Click Yes to continue.
A new window will pop-up showing that the installation package is being verified. You will also be asked to confirm if Docker Desktop shortcuts should be added to the Desktop window, as shown below:
Click on the Ok button on the bottom-left corner to proceed. Docker Desktop will start unpacking and installing the required resources. This process may take some time, depending on your computer’s hardware configurations.
You will see the following window once the Docker Compose installation is complete.
Click on the Close button to exit the installer. You can now start the application by clicking on the Docker Desktop icon on your computer. You can also type Docker Desktop in the search window and then double-click on the app’s icon.
Once the software starts, accept the terms and conditions. You will then be directed to the dashboard, shown below:
Step three: Test the Docker Compose installation.
To check if Docker Compose was installed successfully, launch the command prompt as an administrator. Next, run the following command.
--CODE language-markup--
docker compose version
You should see the Docker Compose version that was installed, as shown below:
macOS
To access Docker Compose, macOS users are required to install Docker for Mac. This software also contains the Docker Machine, Docker CLI client, and Docker Daemon.
Step one: Downloading the Docker installer.
You can access the Docker.dmg file from the official Docker website. Note that you will need to choose an installer depending on your computer chip.
Click on the blue button representing your computer chip to start the download.
Step two: Install Docker.
Locate the Docker.dmg file in the downloads folders. Double-click on this file and then drag and drop the Docker icon in the Applications folder.
To launch the application, double-click on the Docker.app in the applications folder.
A new window will pop up showing the terms and conditions for using Docker. Click Accept to continue to the Docker dashboard.
Step three: Test the Docker installation.
You can check if Docker Compose was installed successfully by running the following command in the terminal.
--CODE language-markup--
docker compose version
Your installed version should be displayed.
Apply your Docker Compose expertise and get a great job
Docker-related skills are in high demand. Many organizations consider Docker containers an essential software toolkit and are using it to deploy containerized applications on multiple platforms. Specialists who use Docker make sure that these deployment processes proceed seamlessly. They monitor logs regularly and push updates whenever errors are detected.
If you are looking for a Docker DevOps role, Upwork makes it easy to connect with clients to complete different projects. Don’t miss out on these great opportunities.
Start applying for Docker jobs on Upwork today.
Upwork is not affiliated with and does not sponsor or endorse any of the tools or services discussed in this article. These tools and services are provided only as potential options, and each reader and company should take the time needed to adequately analyze and determine the tools or services that would best fit their specific needs and situation.