In this tutorial, you’ll install and use Docker Community Edition (CE) . You’ll install Docker itself, work with containers and images, and push an image to a Docker Repository.
Before that you have to the knowledge of some element of docker for more details please refer our Docker Overview post.
Install Docker Engine on CentOS
To get started with Docker Engine on CentOS, make sure you have all of the necessary prerequisites in place before installing Docker.
- You’ll need a supported version of CentOS 7, CentOS 8 (stream), or CentOS 9 to install Docker Engine (stream). Versions that have been archived are not supported or tested.
- It’s necessary to enable the
centos-extras
repository. This repository is enabled by default, but you must re-enable it if you have disabled it. - The
overlay2
storage driver is recommended.
Uninstall old versions
Docker was previously known as docker or docker-engine. If these are already installed, uninstall them as well as any dependencies they may have.
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
It’s OK if yum
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
.
Install Docker Engine
1. Install the latest version of Docker Engine, container, and Docker Compose or go to the next step to install a specific version:
$ sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
2. To install a specific version of Docker Engine, list the available versions in the repo, then select and install:
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-compose-plugin
If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
, and if so, accept it.
This command installs Docker, but it doesn’t start Docker. It also creates a docker
group, however, it doesn’t add any users to the group by default.
Start Docker
$ sudo systemctl start docker
Install Docker Engine on Ubuntu
To get started with Docker Engine on Ubuntu, make sure you have all of the necessary prerequisites in place before installing Docker.
OS requirements :
To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
- Ubuntu Jammy 22.04 (LTS)
- Ubuntu Impish 21.10
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
Docker Engine is supported on x86_64
(or amd64
), armhf
, arm64
, and s390x
architectures.
Uninstall old versions
Docker was previously known as docker, docker.io, or docker-engine. Uninstall these if they’ve been installed:
$ 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. If you do not need to save your existing data, and want to start with a clean installation you have to uninstall docker-engine.
Uninstall Docker Engine
1. Uninstall the Docker Engine, CLI, Container, and Docker Compose packages
$ sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin
2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
$ sudo rm -rf /var/lib/docker $ sudo rm -rf /var/lib/containerd
Install Docker Engine
1. Update the apt
package index and install the most recent versions of Docker Engine, container, and Docker Compose, or proceed to the next step if you want to install a specific version:
$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
2. To install a specific version of Docker Engine, list the available versions in the repo, then select and install:
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin
That is it for today, hope it helps.
If you have any suggestion for this article please make a comment in comment section below.
—
If you like this article, you can buy me a coffee. Thanks!