Docker Compose is a Python program that lets you easily deploy multiple containers on a server.
As you start exploring Docker, you'll learn that often to run a certain web-app, you'll need to run various services (like database, web-server etc) in different containers.
In the official software repository of Ubuntu 20.04, the docker installation package is available by default. However, it isn't the up-to-date version. It's a recommendation to install the latest version of docker from the official docker repository. How can I install Docker 7CE on Ubuntu 20.04 19.04 18.04 16.04 Linux distribution. Docker Engine is a container runtime engine which allows you to package your applications with all of its dependencies into a standardized unit for software development and distribution.
Deploying multiple containers is a lot easier if you use Docker Compose.
Step 2: Create Docker Playbook. The next thing we need to do is create the Ansible playbook that will be used to install Docker and Docker Compose on the Ubuntu servers. Edit the playbook called docker.yml and add the following contents: There is one variable that may need changed called dockercomposeversion. Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04 ( focal ). Finally, install Docker: sudo apt install docker-ce. Docker should now be installed, the daemon started, and the process enabled to start on boot.
In this tutorial, you'll learn two ways of installing Docker Compose on Ubuntu:
- Installing Docker Compose from Ubuntu's repository: Easier method but may not have the latest version of docker compose
- Installing the latest Docker Compose using PIP: Gets you the newer docker compose version
Keep in mind that to use Docker Compose, you must have Docker installed on Ubuntu.
Install Docker Compose from Ubuntu's repository
This is the easiest and recommend method. Unless you need the latest Docker Compose version for some specific reasons, you can manage very well with the docker compose version provides by Ubuntu.
Docker Compose is available in the universe repository of Ubuntu 20.04 and 18.04 so make sure to enable it first:
You probably won't need it but no harm in updating the local cache:
Now you can install Docker Compose in Ubuntu using this command:
You can check that Docker Compose is installed successfully by checking its version:
How To Install Docker On Ubuntu 20.04 Server
It should show an output like this:
Install the latest Docker Compose on Ubuntu using PIP
PIP stands for 'PIP Installs Package'. It's a command-line based package manager for installing Python applications.
Since Docker Compose is basically a Python program, you can use PIP to install it.
But before you do that, you need to install PIP on Ubuntu first.
Install Docker On Ubuntu 20.04 Wsl 2
Enable the universe repository first.
Install PIP now:
Now that you have PIP installed use it to install Docker Compose for all users on your Linux system:
Check the Docker Compose version to ensure that it is installed successfully:
You can see that Docker Compose installed via PIP is more recent version.
Install Docker On Ubuntu 20.04 Server
I hope you were able to successfully install Docker Compose on Ubuntu with this tutorial. I highly recommend reading this quick starter guide to Docker Compose.
Install Docker On Ubuntu 20.04
Questions and suggestions are welcome.
Comments are closed.