Log In

How to Install Docker on Ubuntu

How to Install Docker on Ubuntu
24.11.2023
Reading time: 4 min
Hostman Team
Technical writer

Docker helps developers create lightweight, portable containers that simplify development, testing, and deployment. 

If you decide to work with Docker on Ubuntu, this tutorial will help you to install it.

What is Docker and containerization?

Docker is an open-source platform for creating, deploying, running, and managing containers—isolated environments for launching your apps. 

Containers offer the same functionality and benefits as virtual machines, including application isolation and cost-effective scalability, but also help to optimize resources and increase development productivity. 

Of course, a developer can create containers without Docker (for example, using chroot in Linux), but Docker makes containerization faster, easier, and safer. 

System Requirements

Docker's system requirements are limited to these:

  • kernel version 3.10 or higher;

  • Ubuntu version at least 16.04.

Docker has no hardware requirements as such; it all depends on how it's applied. When choosing Docker as a working tool, consider whether you can work with it comfortably.

-

Installing Docker

Step 1

First, let's update the apt package indexes:

sudo apt update

Step 2

Let's install the packages to access the Docker repository over HTTPS:

sudo apt install apt-transport-https ca-certificates software-properties-common curl 

Step 3

We need to add a GPG key to apt to work with the Docker repository. GPG keys verify software signatures. Run this command:

curl -f -f -s -S -S -L https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 4

Add the Docker repository to the local list:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

Step 5

Once again, let's update the package index:

sudo apt update

Step 6

Install docker. The -y option will automatically answer "Yes" to all the prompts:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

Step 7

Check the Docker status:

sudo systemctl status docker

Here is the complete list of commands to install Docker on Ubuntu:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
sudo systemctl status docker

Installing Docker Compose

In Docker containers, applications run in an isolated environment. However, running multiple related containers that should perform as a single service is more challenging than running a single container.

Managing the launch of multiple containers can be confusing for the user, so it is worth using Docker Compose, one of the Docker tools. Docker Compose helps with the centralized management of many different containers. With Compose, the user defines the system configuration in a single YAML file and starts all containers with a single command.

Installation via Git

To install Docker Compose on Ubuntu via the Git version control system you first need to install Git:

sudo apt-get install git

Type the command git --version into the terminal to check if the installation was successful:

git --version

Output:

git version 2.34.1

To download Docker Compose, enter this command:

gh repo clone docker/compose

Manual installation

To manually install Docker Compose, run this command:

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

Note that we download the version 2.6.1. You may need a different one. You can check available versions here. The uname-s and uname -m parameters will automatically specify the operating system and architecture. After downloading, you may need to change the permissions of the downloaded file:

sudo chmod +x /usr/local/bin/docker-compose

To check the version, you can run this command:

sudo docker-compose --version

Here is a complete list of commands to install Docker Compose via curl on Ubuntu:

sudo curl -L "https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo docker-compose --version

Conclusion

In this tutorial, we have covered how to install Docker and Docker Compose on Ubuntu. Docker is an excellent developer tool, but you will need a powerful computer to use it comfortably. If you want to install Docker on Ubuntu Server and work remotely, you can choose a server at Hostman.


Share