Skip to content
Follow
Ubuntu Linux

How to Install Docker and Docker Compose on Ubuntu Linux

Richard
Written by
Richard
May 22, 2020 Updated Jun 20, 2026 4 min read
How to Enable or Disable Microsoft Defender Cloud Protection
How to Enable or Disable Microsoft Defender Cloud Protection

You install Docker and Docker Compose on Ubuntu Linux by executing commands in your terminal.

Docker is a platform for automating application deployment and management through containerization. Docker Compose helps you define and run multi-container Docker applications, ideal for development setups.

This tutorial guides you through installing Docker Engine version 23.0.6 and the Docker Compose plugin 2.17.2 on Ubuntu 22.04 LTS.

With these tools ready, you can efficiently build, test, and deploy your containerized applications, ensuring they run the same everywhere.

⚡ Quick Answer

Install Docker and Docker Compose on Ubuntu by first updating your package list and installing prerequisite packages. Add Docker’s official GPG key and repository, then install the docker-ce, docker-ce-cli, and containerd.io packages. Finally, install the Docker Compose plugin.

How to add Docker repository on Ubuntu Linux

Adding the official Docker repository to your Ubuntu system ensures you always get the latest updates automatically. This step is crucial for keeping your Docker installation current and secure, making it easier to install Docker Ubuntu.

For this tutorial, we will install the community edition of Docker.

If you always want to get the latest version of Docker on Ubuntu automatically, you must add its official repository to the Ubuntu system. To do that, run the commands below to install prerequisite packages.

🐧Bash / Shell
sudo apt update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Next, run the commands below to download and install Docker’s official GPG key. The key validates packages installed from Docker’s repository, ensuring they’re trusted.

🐧Bash / Shell
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88

You should see an output shown below:

💻Code
Output:
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

Now that the official GPG key has been installed run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.

🐧Bash / Shell
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

At this point, Docker’s official GPG and repository should be installed on Ubuntu.

For those who currently have older versions of Docker, run the commands below to remove them.

🐧Bash / Shell
sudo apt remove docker docker-engine docker.io containerd runc

When you have removed all previous versions of Docker, run the commands below to install the latest and current stable version of Docker.

To install a specific version of Docker, run the apt-cache command. Then, select the version to install.

💻Code
apt-cache madison docker-ce

Output:
docker-ce | 5:18.09.5~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:18.09.4~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:18.09.3~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce | 5:18.09.2~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
.

Now, to install a specific version, run the commands below with the version you wish to install

🐧Bash / Shell
sudo apt-get install docker-ce=5:18.09.5~3-0~ubuntu-bionic docker-ce-cli=5:18.09.5~3-0~ubuntu-bionic containerd.io

If you want the latest version without specifying the above, run the commands below. The command below will always install the highest possible version.

🐧Bash / Shell
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

That should install Docker software on Ubuntu.

Verify that Docker CE is installed correctly by running the hello-world image. Run the commands below:

🐧Bash / Shell
sudo docker run hello-world

You should see a similar line below:

💻Code
Output:
Hello from Docker!
This message shows that your installation appears to be working correctly.

The Docker is installed correctly!

How to install Docker Compose on Ubuntu Linux

You can install Docker Compose on Ubuntu Linux by downloading its binary directly from the GitHub releases page. This method lets you grab the latest version so you can easily install Docker Compose on Ubuntu.

To install it, run the commands below to download version 1.24.0. As of this writing, this is the current version.

🐧Bash / Shell
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

To install a different version of Compose, substitute 1.24.0 with the version of Compose you want to use.

After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary

🐧Bash / Shell
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

That should get Docker Compose working. To test, run the commands below:

💻Code
docker-compose --version

You should see a similar output as below:

💻Code
Output:
docker-compose version 1.24.0, build 0aa59064

That should do it!

To run Docker as a non-root user, add your user account to Docker’s group by running the commands below:

🐧Bash / Shell
sudo usermod -aG docker $USER

Log out and back in, and you should be able to run Docker with your standard account.

Conclusion:

This post showed you how to install Docker and Docker Compose on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.

https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"'.”]

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04
How to Completely Uninstall Docker from Ubuntu
Ubuntu Linux How to Completely Uninstall Docker from Ubuntu
How to Install Supabase with Docker on Ubuntu 24.04
Ubuntu Linux How to Install Supabase with Docker on Ubuntu 24.04

0 Comments

  • DaveD1948

    06/23/2020 – On your main page, and under Docker, you state:

    “Docker software allows visualization at the operating system level..”

    You mean “virtualization” not visualization, and there’s two periods at the end of that same sentence.

    just sayin…

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *