top of page
Writer's pictureShashi Kallae

Install Docker Engine on RHEL9.x/8.X/7.x server



Pre-Requisites to install Docker Engine on RHEL 9.x/8.x/7.x server

  • To install Docker Engine, you must have the below versions or Redhat Linux.

    1. RHEL 9.x

    2. RHEL 8.x

    3. RHEL 7.x

  • Uninstall any older versions of Docker engines.

    1. Older versions of Docker go by the name docker or docker-engine. Uninstall any older versions before installing a new version of Docker Engine and associated dependencies.

    2. Also, uninstall Podman and the related dependencies, if installed already, before proceeding further.

    3. Clean up all the related environment variables that were set in the .bash_profile. This is only needed if the env variables are called from the.bash_profile; otherwise, ignore this.

 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine \
                  podman \
                  runc
  1. 'YUM' might report that none of these packages are installed. Images, containers, volumes, and networks are located at /var/lib/docker/, and these aren't automatically removed when you execute the above remove command.

  2. To resolve this, find out the related older docker images, files, and directories and delete them manually.


Step-by-Step Installation procedure

  • Login to the RHEL8.x/7.x Server

    • sudo to root (You must be logged in as root or root equivalent privileged user).

  • Set up a proxy before downloading the binaries. Double-check with your security team and get their approval before downloading anything.

export http_proxy="http://proxyXYZ.company.com" 
export https_proxy=$http_proxy
export no_proxy=".company.net,localhost,127.0.0.1,localaddress,.localdomain.com,.docker.company.net"
export NO_PROXY=".company.net,localhost,127.0.0.1,localaddress,.localdomain.com,.docker.company.net"
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$HTTP_PROXY

If you don't want to set these environment variables, you must prepend all the commands that reach the external Docker repositories with the proxy information.

  • Set up the docker-ce repos. The below command should create the repo file: /etc/yum.repos.d/docker-ce.repo

yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
  • Add the centos-extras repo. You may have to create a new repo file and add the following.

[centos-extras]
name=Centos extras - $basearch
baseurl=http://mirror.centos.org/centos/7/extras/x86_64
enabled=0
gpgcheck=1
gpgkey=http://centos.org/keys/RPM-GPG-KEY-CentOS-7
  • Disable all the existing unused repos

This step isn't needed, but it is recommended before wrapping up the task and exiting from the server. This command will disable the repos brought in, so they aren't queried every time you run a 'YUM' command. The reason is that whenever you log in to this server and execute the 'YUM' command, it will attempt to query the remote repositories and pull the repomod.xml only if you have set the proxies, as mentioned earlier. Otherwise, it will be in a stuck state and timeout, creating a lot of headaches.


Use the sed command to disable the remote repositories.

sed -i.bak 's/enabled=1/enabled=0/g' /etc/yum.repos.d/docker-ce.repo
  • Install the dependencies from the Centos repository.

yum --disablerepo="*" --enablerepo="centos-extras" install slirp4netns fuse-overlayfs container-selinux
  • Install Docker

yum --disablerepo="*" --enablerepo="docker-ce-stable" install docker-ce docker-ce-cli containers.io
  • Start/Enable Docker service to be started on reboot.

systemctl start docker
systemctl enable docker
  • Verify the Docker Engine Installation by running the below command,

docker run hello-world (Make sure you are sudo'd to root).

Special considerations

1) If you want to install a specific version of Docker Engine, then execute the below command.

yum list docker-ce --showduplicates | sort -r

This will display the following,

yum list docker-ce --showduplicates | sort -r

docker-ce.s390x    3:24.0.0-1.el8    docker-ce-stable
docker-ce.s390x    3:23.0.6-1.el8    docker-ce-stable
<...>

2) If you want to install yum-utils package, which provides yum-config-manager utility, execute the below,

sudo yum install -y yum-utils

Use yum-config-manager as below,

 sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo 




Citations:

  1. https://docs.docker.com/engine/install/rhel/


留言

評等為 0(最高為 5 顆星)。
暫無評等

新增評等
bottom of page