How to install Docker on Ubuntu Linux Systems. Tutorial on installing Docker on Linux Ubuntu 20.04.
Docker
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Docker is a platform for developers and sysadmins to build, run, and share applications with containers. The use of containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is.
Containerization is increasingly popular because containers are:
- Flexible: Even the most complex applications can be containerized.
- Lightweight: Containers leverage and share the host kernel, making them much more efficient in terms of system resources than virtual machines.
- Portable: You can build locally, deploy to the cloud, and run anywhere.
- Loosely coupled: Containers are highly self sufficient and encapsulated, allowing you to replace or upgrade one without disrupting others.
- Scalable: You can increase and automatically distribute container replicas across a datacenter.
- Secure: Containers apply aggressive constraints and isolations to processes without any configuration required on the part of the user.
By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.
The Three Release Channels
Docker Engine has three types of update channels, stable, test, and nightly:
- The Stable channel gives you latest releases for general availability.
- The Test channel gives pre-releases that are ready for testing before general availability (GA).
- The Nightly channel gives you latest builds of work in progress for the next major release.
1. Stable
Year-month releases are made from a release branch diverged from the master branch. The branch is created with format ., for example 18.09. The year-month name indicates the earliest possible calendar month to expect the release to be generally available. All further patch releases are performed from that branch. For example, once v18.09.0 is released, all subsequent patch releases are built from the 18.09 branch.
2. Test
In preparation for a new year-month release, a branch is created from the master branch with format YY.mm when the milestones desired by Docker for the release have achieved feature-complete. Pre-releases such as betas and release candidates are conducted from their respective release branches. Patch releases and the corresponding pre-releases are performed from within the corresponding release branch.
3. Nightly
Nightly builds give you the latest builds of work in progress for the next major release. They are created once per day from the master branch with the version format: 0.0.0-YYYYmmddHHMMSS-abcdefabcdef where the time is the commit time in UTC and the final suffix is the prefix of the commit hash, for example 0.0.0-20180720214833-f61e0f7.
Install the latest version of Docker
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
* Ubuntu Eoan 19.10
* Ubuntu Bionic 18.04 (LTS)
* Ubuntu Xenial 16.04 (LTS)
Docker Engine is supported on x86_64 (or amd64), armhf, arm64, s390x (IBM Z), and ppc64le (IBM Power) architectures.
NOTE: Before you install the latest version of Docker, you must uninstall old versions. Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:
sudo apt-get remove docker docker-engine docker.io containerd runc
It’s OK if apt-get reports that none of these packages are installed.
The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker Engine package is now called docker-ce.
To install the latest version of Docker, run the commands below:
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent 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 $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Install a specific version of Docker
To install a specific version, first list all the available versions in the Docker repository:
sudo apt update
apt list -a docker-ce
NOTE: The available Docker versions are printed in the second column. Note down the version number and use the following set of commands to install Docker:
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg-agent 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 $(lsb_release -cs) stable"
sudo apt install docker-ce= docker-ce-cli= containerd.io
NOTE: Change the desired version number in the last code of command – VERSION.
Once the installation is completed, the Docker service will start automatically. You can verify it by typing:
sudo systemctl status docker
NOTE: When a new version of Docker is released, you can update the packages using the standard sudo apt update && sudo apt upgrade procedure.
Uninstall Docker
Run the following commands to stop all running containers and remove all docker objects from the Linux Ubuntu System:
docker container stop $(docker container ls -aq)
docker system prune -a --volumes
sudo apt purge docker-ce
sudo apt autoremove
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:
sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
You must delete any edited configuration files manually