
Docker application is used to manage application processes in container. Using docker you can build, test and deploy applications that can run anywhere as portable and self-sufficient containers. In this tutorial, we will learn how to install Docker on Ubuntu 20.04.
Prerequisites
Before you start install, you must have non-root user account with sudo privileges.
Installing Docker on Ubuntu
We will install latest Docker package on Ubuntu system from the Docker’s repositories. Docker is also available in the standard Ubuntu 20.04 repositories, but it may not always be the latest version.
Perform the following steps to install docker on Ubuntu 20.04.
First, Update the package manager index list and upgrade the system to latest using below:
sudo apt update && sudo apt upgrade
We also need to install dependencies which are required to enable Docker repository.
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Now Import the GPG key for repository using following curl command:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
After that, add Docker repository to your system’s software repository list by typing:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
Now Docker repository is enabled so update apt package manager index list again using below command:
sudo apt update
Install latest version of Docker Community Edition using below:
sudo apt install docker-ce
Once the installation completed the service of docker will start automatically. You can check it by issuing below command:
sudo systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-05-23 07:25:01 UTC; 42s ago ...
At the time of writing, the latest stable version of Docker is 19.03.1
. You also can check the version of Docker using below command:
docker -v
Docker version 19.03.1, build 74b1e89
Executing docker command without sudo
By default, Docker
required sudo
privileges to run. If you want to run docker command without sudo then you need to add your user to docker group
. The docker group is created at the installation of docker CE package.
You should run below command to add user to docker group:
sudo usermod -aG docker $USER
After that, Log out and log back in to apply membership.
Run the below command to verify that you have added docker group :
id -nG
tecnstuff sudo docker
How to Use Docker Command
Below is the basic syntax for the docker
command:
docker [option] [subcommand] [arguments]
You can get list of all docker subcommands by issuing below command:
docker
If you need any help about subcommand then you can use following command:
docker docker-subcommand --help
Upgrading Docker
You can update docker new version when it is released. You just have to run below commands:
sudo apt update
sudo apt upgrade
Uninstalling Docker
Uninstall process of Docker is same as any other packages installed using apt:
sudo apt purge docker-ce
sudo apt autoremove
Conclusion
You learned how to install docker on Ubuntu 20.04 system. To learn more about Docker check out the official Docker documentation.
If you have any question or suggestion, please leave a comment below.