Docker Install

Install and Configure Docker for Ubuntu.
Installation
Prerequisites
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
- Ubuntu Hirsute 21.04
- Ubuntu Groovy 20.10
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
- Ubuntu Xenial 16.04 (LTS)
Uninstall old versions
Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:
Set up the repository
Update the apt package index and install packages to allow apt to use a repository over HTTPS:
Add Docker’s official GPG key:
Use the following command to set up the stable repository for x86_64
Ubuntu versions:
Install Docker Engine
Update the apt package index, and install the latest version of Docker Engine and containerd:
Verify that Docker Engine is installed correctly by running the hello-world image:
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
Docker Engine is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to allow non-privileged users to run Docker commands.
Post-installation
This section contains optional procedures for configuring Linux hosts to work better with Docker.
Manage Docker as a non-root user
The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root
and other users can only access it using sudo
. The Docker daemon always runs as the root
user.
If you don’t want to preface the docker
command with sudo
, create a Unix group called docker
and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker
group.
After the installation usually the docker
group is created, but no users are added. To check the existence of the docker
group run:
If you do not see any output, create it with:
Add your user to the docker
group:
Log out and log back in so that your group membership is re-evaluated, or run:
Verify that you can run docker commands without sudo
:
Configure Docker to start on boot
Most current Linux distributions (RHEL, CentOS, Fedora, Debian, Ubuntu 16.04 and higher) use systemd
to manage which services start when the system boots. On Debian and Ubuntu, the Docker service is configured to start on boot by default.
To automatically start Docker and Containerd on boot for other distros, use the commands below:
To disable this behavior, use disable
instead:
Uninstall
Uninstall Docker Engine
Uninstall the Docker Engine, CLI, and Containerd packages:
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes: