Install Docker Engine (CE) on RHEL 7.x

By | November 12, 2020

Docker Engine is an open source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with:

  • A server with a long-running daemon process dockerd.
  • APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon.
  • A command line interface (CLI) client docker.

Credit to Docker.

This below is the simple way to install Docker Engine Community Edition on Red Hat Enterprise Linux 7.x server:

1. Demonstration LAB Info

  • OS: Red Hat Enterprise Linux 7.x x86_64
  • Hostname: RH7LXCSTD
  • IP: 192.168.100.20
  • CPU: 2 Cores
  • RAM: 2 GB
  • Disk: 30 GB

2. Let iptables see bridged traffic

cat <<EOF | sudo tee /etc/sysctl.d/iptables-bridge.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
modprobe br_netfilter
sysctl --system

3. Remove existing old Docker version

sudo yum remove \
        docker \
        docker-client \
        docker-client-latest \
        docker-common \
        docker-latest \
        docker-latest-logrotate \
        docker-logrotate \
        docker-engine
sudo rm -rf /etc/yum.repos.d/docker-ce*.repo

4. Install additional required packages

  • Configure local repository to install packages from RHEL disk
  • Install packages as the following
sudo yum install \
        device-mapper-persistent-data \
        yum-utils \
        lvm2

5. Add Docker CE official repository and required additional repository

  • Fix RHEL 7.x release version
echo 7 > /etc/yum/vars/releasever
  • Docker CE official repository
sudo yum-config-manager \
        --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • Create custom repository to install Docker dependency packages on RHEL 7.x. Note: we do not have RHEL subscription repository that is why I use dependency packages from CentOS 7.x instead
cat <<EOF | sudo tee /etc/yum.repos.d/docker-ce-deps.repo
[docker-ce-deps]
name=Docker Deps on RHEL7.x
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
cat <<'EOF' | sudo tee /etc/yum.repos.d/docker-ce-deps.repo
[docker-ce-deps]
name=Docker Deps on RHEL7.x
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=0
enabled=1
includepkgs=container-selinux slirp4netns fuse-overlayfs fuse3-libs
EOF

6. Install Docker Engine CE (online). Note: we must have internet connection!!!

sudo yum install \
        docker-ce \
        docker-ce-cli \
        containerd.io

7. Enable and start Docker Engine service

systemctl enable docker --now

8. Verify Docker CE version and Info

docker --version
docker info

9. Install Docker Compose. Check docker-compose version here

compose_ver=1.27.4
curl -L -k "https://github.com/docker/compose/releases/download/$compose_ver/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose && \
ln -s /usr/local/bin/docker-compose /usr/sbin/docker-compose && \
docker-compose --version

10. Verify that Docker Engine is installed correctly by running the “hello-world” image:

docker run hello-world

Thanks!

One thought on “Install Docker Engine (CE) on RHEL 7.x

  1. Pingback: Deploy Oracle Database container on Docker - Systems & Network Administrator

Leave a Reply

Your email address will not be published. Required fields are marked *