How To Install Docker and Docker Compose on Ubuntu 20.04 in Two Simple Ways
Install Docker and Docker Compose on Ubuntu 20.04 Quickly and Securely with Official Repository or Docker’s Convenience Script
Install Docker and Docker Compose on Ubuntu 20.04 using apt by adding Docker’s official repository
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
Verify that Docker was installed correctly by running the command:
You should see the version number of Docker that you just installed
Install Docker Compose:
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
sudo chmod +x /usr/local/bin/docker-compose
Verify that Docker Compose was installed correctly by running the command:
docker-compose --version
You should see the version number of Docker Compose that you just installed.
After completing these steps, Docker and Docker Compose should be installed on your system.
Install Docker and Docker Compose on Ubuntu 20.04 using the convenience script provided by Docker
Install Docker
This example downloads the script from https://get.docker.com/ and runs it to install the latest stable release of Docker on Linux:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Check if Docker is running:
sudo systemctl status docker
Install Docker Compose
Download the current stable release of Docker Compose:
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
Note: This command downloads Docker Compose version 1.29.2, but you can check the latest version from the Docker Compose release page and replace the version number in the command if needed.
Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
Verify that Docker Compose was installed correctly by running the command:
docker-compose --version
You should see the version number of Docker Compose that you just installed.
For more details check This
That’s it! You now have Docker and Docker Compose installed on your Ubuntu 20.04 system.