A better way to install Docker on CentOS 8
If you’d prefer the latest version of docker-ce (as well as a functioning upgrade), use this method of installation on CentOS 8.
Recently I penned a tutorial on installing docker-ce on CentOS 8 (see: How to install Docker CE on CentOS 8). Although those steps will get you want you want (a working instance of the Docker Community Edition), when you go to update/upgrade CentOS, you’ll find there’s a bit of a problem. Said problem is centered around the containerd.io package (Figure A).
You can certainly get around this by installing docker-ce with the –nobest option, which could still wind up with a CentOS upgrade issue. The better method is via a bit of manual installation. And that’s exactly what I’m going to show you. With this method, you shouldn’t have any problems when you go to upgrade CentOS.
SEE: Hybrid cloud: A guide for IT pros (TechRepublic download)
What you’ll need
The only things you’ll need to make this work are:
- A running instance of CentOS 8
- A user account with sudo privileges
How to install docker-ce
If you haven’t already installed docker-ce, let’s refresh. Here are the steps:
- Install docker-ce with the command sudo dnf install docker-ce-3:18.09.1-3.el7.
- If necessary, force DNS resolution in Docker containers with the command sudo systemctl disable firewalld. If you do not need DNS resolution within your containers, do not run that command.
- Start and enable the Docker daemon with the command sudo systemctl enable –now docker.
- Add your user to the docker group with the command sudo usermod -aG docker $USER.
- Log out and log back in.
Now that you have docker-ce installed, let’s make it possible for you to upgrade CentOS without errors.
How to install the containerd.io package
To install the containerd.io package, go back to the terminal window and issue the command:
sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
The secondary benefit of installing containerd.io manually, is that you can now install the latest version of docker-ce, as opposed to installing an older, specific version. Install the latest docker-ce release with the command:
sudo dnf install docker-ce
Once that installs, you should now be able to upgrade CentOS without issue.
Congratulations, you have the latest version of docker-ce and a perfectly functioning dnf system in CentOS 8.