Docker is an open-source containerization platform that allows you to quickly build, test, and deploy applications as portable containers that can run virtually anywhere. A container represents a runtime for a single application and includes everything the software needs to run.
There are two versions of Docker – Docker CE (Community Edition) and Docker EE (Enterprise Edition). If you have a small-scale project, or you’re just learning, you will want to use Docker CE.
In this post covers how to install Docker on an Ubuntu 20.04.
First, update the packages index and install the dependencies necessary:
$ sudo apt update $ sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Import the repository’s GPG key using the following
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker APT repository to your system:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Second, install docker with latest version:
$ sudo apt update $ sudo apt install docker-ce docker-ce-cli containerd.io
Once the installation is completed, the Docker service will start automatically. You can verify it by typing:
$ sudo systemctl status docker
Executing Docker Commands as a Non-Root User
$ sudo usermod -aG docker $USER
Verifying the Installation
$ docker container run hello-world
The command will download the test image, if not found locally, run it in a container, print a “Hello from Docker” message, and exit.
Run the following commands to stop all running containers and remove all docker objects:
$ docker container stop $(docker container ls -aq) $ docker system prune -a --volumes
You can now uninstall Docker as any other package installed with
$ sudo apt purge docker-ce $ sudo apt autoremove
Enjoy your docker!