Docker is a set of Platform as a Service (PaaS) products that uses operating system level virtualizations to deliver software in the form of containers. Docker CE (Community Edition) is the strip down version of Docker EE (Enterprise Edition). Community Edition is free and open source and distributed under Apache License 2.0.
In Red Hat Enterprise Linux (RHEL) 8 / CentOS 8, Support of Docker has been removed by the vendor. Whereas a new containerization platform libpod (Podman's Container Management Library) has been introduced as an alternative of Docker.
However, we can still install Docker and it’s dependencies on CentOS 8 / RHEL 8 from third party yum repositories.
In this article, we are installing Docker CE and docker-compose on CentOS 8.
Table Of Contents:
- Environment Specification
- Adding Docker CE Official Yum Repository
- Installing Docker CE on CentOS 8
- Create a Container using Docker Command
- Installing Docker-compose on CentOS 8
Environment Specification:
We have configured a CentOS 8 (minimal) virtual machine with following specification.
- CPU - 3.4 Ghz (2 cores)
- Memory - 2 GB
- Storage - 20 GB
- Operating System - CentOS 8.0
- Hostname - docker-01.recipes.com
- IP Address - 192.168.116.206 /24
Adding Docker CE Official Yum Repository:
Connect with docker-01.recipes.com using ssh as root user.
Docker CE is available to download from Docker's official website. However, we can also install it from Docker CE yum repository.
Add Docker CE yum repository using dnf command.
# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
Build cache for Docker yum repository.
# dnf makecache
CentOS-8 - AppStream 7.0 kB/s | 4.3 kB 00:00
CentOS-8 - Base 2.2 kB/s | 3.9 kB 00:01
CentOS-8 - Extras 1.7 kB/s | 1.5 kB 00:00
Docker CE Stable - x86_64 6.5 kB/s | 21 kB 00:03
Metadata cache created.
Installing Docker CE on CentOS 8:
After addition of Docker CE yum repository, we can now easily install Docker CE on CentOS 8 by using a dnf command.
Docker CE requires containerd.io-1.2.2-3 (or later) package, which is blocked in CentOS 8. Therefore, we have to use an earlier version of containerd.io package.
Install docker-ce with an earlier version of containerd.io using following command.
# dnf -y install --nobest docker-ce
Enable and start Docker service.
# systemctl enable --now docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service â /usr/lib/systemd/system/docker.service.
Check status of Docker service.
# systemctl status docker.service
â docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor pres>
Active: active (running) since Wed 2019-12-25 22:56:45 PKT; 30s ago
Docs: https://docs.docker.com
Main PID: 3139 (dockerd)
Tasks: 17
Memory: 66.9M
CGroup: /system.slice/docker.service
ââ3139 /usr/bin/dockerd -H fd://
ââ3148 containerd --config /var/run/docker/containerd/containerd.tom>
Dec 25 22:56:45 docker-01.recipes.com dockerd[3139]: time="2019-12-25T22:56:45.>
Dec 25 22:56:45 docker-01.recipes.com systemd[1]: Started Docker Application Co>
Check Docker version.
# docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.39 (downgraded from 1.40)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.1
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:06:30 2019
OS/Arch: linux/amd64
Experimental: false
Docker CE has been installed on CentOS 8.
Create a Container using Docker Command:
Let's put Docker into action by creating a simple container.
For this purpose, we are using official image of Alpine Linux from Docker Hub.
# docker search alpine --filter is-official=true
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
alpine A minimal Docker image based on Alpine Linux⦠5945 [OK]
Pull Alpine Linux image from Docker Hub.
# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
e6b0cf9c0882: Pull complete
Digest: sha256:2171658620155679240babee0a7714f6509fae66898db422ad803b951257db78
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
List locally available docker images.
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest cc0abc535e36 23 hours ago 5.59MB
Create and run a container using Alpine Linux image.
# docker run -it --rm alpine /bin/sh / # cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.11.2 PRETTY_NAME="Alpine Linux v3.11" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/" / # uname -a Linux c0089c037e24 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 Linux / # exit
Installing Docker-compose on CentOS 8:
Additionally, we are installing docker-compose on our CentOS 8 server, so we can create and run multiple containers as a single service.
Download docker-compose package from GitHub.
# curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 546 0 --:--:-- 0:00:01 --:--:-- 546
100 16.2M 100 16.2M 0 0 184k 0 0:01:29 0:01:29 --:--:-- 276k
Grant execute permissions to docker-compose command.
# chmod +x /usr/local/bin/docker-compose
Check docker-compose version.
# docker-compose version
docker-compose version 1.25.1-rc1, build d92e9bee
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
We have successfully installed Docker CE and Docker-Compose on CentOS 8. We have only explored the installation of Docker CE here, if you wish to learn more about containers then you should read Docker in Action by Manning Publications.
No comments:
Post a Comment