How to Install Docker and Docker-Compose To Ubuntu 20.04, Azure VM and AWS EC2 instances
First, update your existing list of packages
sudo apt update
Installing Docker
Install the necessary packages to allow apt to use a repository over HTTPS:
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to your system:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
Update the apt package index again:
sudo apt-get update
Finally, install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io
Once the installation is complete, you can check the version of Docker that you installed by running:
docker --version
That’s it! Docker should now be installed on your Ubuntu 20.04 system.
Installing Docker Compose
Download the Docker Compose binary into the /usr/local/bin directory with the following command:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
This command will download the latest version of Docker Compose
Make the Docker Compose binary executable:
sudo chmod +x /usr/local/bin/docker-compose
Verify that Docker Compose was installed correctly by running:
docker-compose --version
That’s it! Docker Compose should now be installed on your Ubuntu 20.04 system.