How to Install Docker on Ubuntu
Docker helps developers create lightweight, portable containers that simplify development, testing, and deployment.
If you decide to work with Docker on Ubuntu server, this tutorial will help you to install it.
What is Docker and containerization? Copy link
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. By the way, modern SaaS teams often launch their cloud based application using a fully managed application platform.
System Requirements Copy link
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 Copy link
Step 1
First, let's update the apt package indexes:
sudo apt updateStep 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 updateStep 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 -yStep 7
Check the Docker status:
sudo systemctl status dockerHere 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 -
Installing Docker Compose Copy link
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.
Note: If you’re deploying containers in production, consider using managed Kubernetes to reduce operational overhead.
Installation via Git Copy link
To install Docker Compose on Ubuntu via the Git version control system you first need to install Git:
sudo apt-get install gitType the command git --version into the terminal to check if the installation was successful:
git --versionOutput:
git version 2.34.1To download Docker Compose, enter this command:
gh repo clone docker/composeManual installation Copy link
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-composeNote 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-composeTo check the version, you can run this command:
sudo docker-compose --versionHere 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 --versionConclusion Copy link
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 an inexpensive VPS server at Hostman.