Installing Docker CE and Docker compose on RHEL8 or RHEL9

Learn how to install Docker CE and Docker compose on Red Hat Enterprise Linux (RHEL) 8 using dnf or yum commands. You can also find information about resolving Docker CE container connectivity issue in this section.

Install Docker CE and Docker compose on RHEL 8 or RHEL 9 using dnf commands

Before you begin:
  • You need a valid Red Hat subscription and account credentials to perform these actions. For detailed prerequisites, refer to Prerequisites and requirements.
  • Uninstall Podman.
    Important: To ensure proper execution of MCM startup scripts, Podman must be uninstalled, if it is installed in BigFix MDM server. This is because the presence of Podman can create conflicts with Docker, which is used as the container runtime for MCM service.
    • DNF command to remove Podman
      sudo dnf remove podman
    • Yum command to remove Podman
      sudo yum remove podman
      sudo hash -r

To install Docker CE and Docker compose on RHEL 8:

  1. Add a subscription on a RHEL 8 system. To do that, complete the following steps:
    1. Register the system:
      sudo subscription-manager register
      This command prompts you to enter your Red Hat account credentials. After successful registration, the system is associated with your Red Hat account.
    2. Refresh:
      sudo subscription-manager refresh
      This command manually refreshes the local system's subscription information.
    3. Attach a subscription:
      sudo subscription-manager attach --auto
      This command automatically attaches available subscriptions to your system.
    For more details on adding a subscription on a RHEL 8 system, see https://access.redhat.com/solutions/253273
  2. Add the external repository by running the following command.
    sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
    1. Verify whether the repository has been enabled. To do that, run the following command that returns detailed information about all the enabled repositories.
      sudo dnf repolist -v
  3. Install the latest available containerd.io package manually.
    sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.6.28-3.2.el7.x86_64.rpm
  4. Install docker engine.
    sudo dnf -y install docker-ce-cli
    sudo dnf -y install docker-ce
  5. Start and enable the docker daemon
    sudo systemctl enable --now docker
    1. Confirm whether the daemon is active by running this command:
      systemctl is-active docker
  6. Install docker-compose globally.
    1. Download the binary file from the project’s GitHub page:
      curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o docker-compose
    2. After the binary file is downloaded, move it to the /usr/local/bin folder, and then make it executable:
      sudo mv docker-compose /usr/local/bin && sudo chmod +x /usr/local/bin/docker-compose
      sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose 

For detailed information, see https://linuxconfig.org/how-to-install-docker-in-rhel-8

After this installation, you might encounter a Docker CE container connectivity issue. Complete these steps to resolve this issue.

Install Docker CE and Docker compose on RHEL 8 or RHEL 9 using yum

Before you begin: You need a valid Red Hat subscription and account credentials to perform these actions.

To install Docker CE and Docker compose on RHEL 8:

  1. Add a subscription on a RHEL 8 system. To do that, complete the following steps:
    1. Register the system:
      sudo subscription-manager register
      This command prompts you to enter your Red Hat account credentials. After successful registration, the system is associated with your Red Hat account.
    2. Refresh:
      sudo subscription-manager refresh
      This command manually refreshes the local system's subscription information.
    3. Attach a subscription:
      sudo subscription-manager attach --auto
      This command automatically attaches available subscriptions to your system.
    4. sudo yum install -y yum-utils
    For more details on adding a subscription on a RHEL 8 system, see https://access.redhat.com/solutions/253273
  2. Add the external repository by running the following command.
    sudo yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
  3. sudo yum -y install docker-ce-cli
    sudo yum -y install docker-ce
  4. Start and enable the docker daemon
    sudo systemctl enable --now docker
    1. Confirm whether the daemon is active by running this command:
      systemctl is-active docker
  5. Install docker-compose globally.
    1. Download the binary file from the project’s GitHub page:
      curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o docker-compose
    2. After the binary file is downloaded, move it to the /usr/local/bin folder, and then make it executable:
      sudo mv docker-compose /usr/local/bin && sudo chmod +x /usr/local/bin/docker-compose
      sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose 

For detailed information, see https://linuxconfig.org/how-to-install-docker-in-rhel-8

After this installation, you might encounter a Docker CE container connectivity issue. Complete these steps to resolve this issue.

Resolve Docker CE container connectivity issue

To resolve Docker CE container connectivity issue:
  1. Check which interface Docker is using. For example, 'docker0'.
    ip link show
  2. Check available firewalld zones. For example, 'public'
    sudo firewall-cmd --get-active-zones
  3. Check which zone the Docker interface is bound to. Typically, the Docker interface is not bound to a zone yet.
    sudo firewall-cmd --get-zone-of-interface=docker0
  4. Add the 'docker0' interface to the 'public' zone. Changes are visible only after the firewalld is reloaded
    sudo nmcli connection modify docker0 connection.zone public
  5. Masquerading enables Docker ingress and egress.
    sudo firewall-cmd --zone=public --add-masquerade --permanent
  6. Reload the firewalld
    sudo firewall-cmd --reload
  7. Restart dockerd
    sudo systemctl restart docker