How Do You Install Docker on Red Hat 9?

In today’s fast-evolving tech landscape, containerization has become a cornerstone for developers and system administrators alike. Docker, a leading container platform, streamlines application deployment by packaging software into standardized units called containers. If you’re working with Red Hat Enterprise Linux 9 (RHEL 9), mastering how to install Docker on this robust operating system can significantly enhance your development workflow and operational efficiency.

Red Hat 9 offers a stable and secure environment, making it an excellent choice for running containerized applications. However, installing Docker on this platform involves understanding compatibility nuances and configuring your system to support container technology effectively. Whether you’re aiming to set up a local development environment or deploy scalable applications in production, getting Docker up and running on RHEL 9 is a crucial first step.

This article will guide you through the essentials of installing Docker on Red Hat 9, ensuring you have a solid foundation to leverage containerization’s full potential. From preparing your system to verifying a successful installation, you’ll gain the insights needed to confidently integrate Docker into your Red Hat ecosystem.

Configuring the System for Docker Installation

Before installing Docker on Red Hat Enterprise Linux 9, it is essential to prepare the system to ensure compatibility and smooth operation. Docker requires certain kernel features and package repositories that may not be enabled by default.

Begin by updating your system to the latest packages using the following command:

“`bash
sudo dnf update -y
“`

Docker depends on kernel features such as cgroups and namespaces, which are included in Red Hat 9’s kernel by default. However, enabling the Docker repository and configuring SELinux correctly is crucial.

Enable the `extras` and `crb` repositories, which provide the necessary dependencies for Docker:

“`bash
sudo dnf config-manager –set-enabled crb
sudo dnf config-manager –set-enabled extras
“`

Next, install required packages to allow `dnf` to use repositories over HTTPS:

“`bash
sudo dnf install -y dnf-plugins-core
“`

Docker requires a repository source. Red Hat provides container tools repositories, but the official Docker repository can also be configured for the latest versions.

To configure the Docker CE repository, create a new repository file:

“`bash
sudo tee /etc/yum.repos.d/docker-ce.repo <Installing Docker Engine on Red Hat 9

With the system prepared, proceed to install Docker Engine. The `dnf` package manager is used to install Docker components.

First, clear any existing Docker installations to avoid conflicts:

“`bash
sudo dnf remove -y docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
“`

Then, install the Docker Engine package and its dependencies:

“`bash
sudo dnf install -y docker-ce docker-ce-cli containerd.io
“`

After installation completes, enable and start the Docker service to allow it to run on system startup:

“`bash
sudo systemctl enable docker
sudo systemctl start docker
“`

Verify Docker is running correctly:

“`bash
sudo systemctl status docker
“`

You can also test Docker by running the hello-world container:

“`bash
sudo docker run hello-world
“`

This command downloads and runs a test container, confirming that Docker Engine is functioning properly.

Managing Docker as a Non-root User

By default, Docker commands require root privileges. To manage Docker as a non-root user, add your user account to the `docker` group.

Add your user to the group with:

“`bash
sudo usermod -aG docker $USER
“`

After this change, log out and back in or reboot the system to apply group membership.

This enables running Docker commands without `sudo`, improving convenience and security. However, be aware that members of the `docker` group effectively have root-level access to the system through Docker.

Common Docker Commands and Usage on Red Hat 9

Once Docker is installed and configured, familiarize yourself with essential Docker commands to manage containers and images efficiently.

  • Pull an image from Docker Hub:

“`bash
docker pull
“`

  • List downloaded images:

“`bash
docker images
“`

  • Run a new container:

“`bash
docker run -d –name -p :
“`

  • List running containers:

“`bash
docker ps
“`

  • Stop a running container:

“`bash
docker stop
“`

  • Remove a container:

“`bash
docker rm
“`

  • Remove an image:

“`bash
docker rmi
“`

The table below summarizes key Docker commands and their purposes:

Command Description Example
docker pull Download an image from a registry docker pull nginx
docker run Create and start a container docker run -d -p 80:80 nginx
docker ps List running containers docker ps
docker stop Stop a container docker stop my_nginx
docker rm Remove a stopped container docker rm my_nginx
docker rmi Remove an image docker rmi nginx

Preparing the Red Hat 9 System for Docker Installation

Before installing Docker on Red Hat Enterprise Linux (RHEL) 9, it is essential to ensure the system is updated and properly configured for Docker’s requirements. This preparation minimizes compatibility issues and sets the foundation for a successful installation.

Begin by verifying the system’s current packages and applying necessary updates:

  • Update existing packages: Run sudo dnf update -y to fetch and install the latest security patches and software versions.
  • Install essential utilities: Confirm that dnf-plugins-core is installed, which aids in managing repositories:
sudo dnf install -y dnf-plugins-core

Docker requires specific kernel features and cgroup configurations. Verify that the kernel version meets the minimum requirement (usually Linux kernel 3.10 or later), which RHEL 9 inherently satisfies. Also, ensure SELinux is configured properly to avoid conflicts with container operations.

Component Recommended Configuration Verification Command
Kernel Version 3.10 or newer uname -r
SELinux Mode Enforcing or Permissive (configure policies accordingly) sestatus
Firewall Allow Docker-related ports or disable if managed externally sudo firewall-cmd --list-all

Adjust SELinux policies if necessary to permit container operations without compromising security. For example, setting SELinux to permissive mode during initial setup can isolate issues, but returning to enforcing mode with proper policies is best practice.

Enabling the Docker Repository and Installing Docker Engine

Docker packages are not included in the default RHEL 9 repositories. You must enable the official Docker repository or use the RHEL extras repository if available. The following steps demonstrate adding the Docker CE repository and installing Docker Engine.

  • Set up the Docker repository: Use the dnf config-manager utility to add the Docker repository.
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

This repository is compatible with RHEL-based distributions, including RHEL 9.

  • Install Docker Engine components: Install the latest stable Docker packages using dnf.
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

This command installs:

Package Description
docker-ce The Docker Community Edition engine
docker-ce-cli Docker command-line interface
containerd.io Container runtime required by Docker
docker-buildx-plugin Buildx plugin for advanced image building capabilities
docker-compose-plugin Plugin to run Docker Compose V2

After installation, verify Docker’s availability by checking the installed version:

docker --version

Starting and Configuring Docker Service

Once Docker packages are installed, the Docker daemon must be started and enabled to launch automatically on system boot. Managing the service via systemctl ensures persistent availability.

  • Start the Docker service:
sudo systemctl start docker
  • Enable Docker to start on boot:
sudo systemctl enable docker

Confirm the Docker service status to ensure it is active and running:

sudo systemctl status docker

Enable the current user to run Docker commands without requiring sudo by adding the user to the docker group:

sudo usermod -aG docker $USER

After this change, the user must log out and log back in for group membership to refresh.

Verifying Docker Installation and Running a Test Container

Verification of the Docker installation involves running a test container to confirm that Docker can pull images and start containers properly.

  • Pull and run the official hello-world image:
docker run hello-world

This command performs the following operations:

  • Pulls the hello-world image from Docker

    Expert Insights on Installing Docker on Redhat 9

    Dr. Elena Martinez (Senior DevOps Engineer, CloudScale Solutions). Installing Docker on Redhat 9 requires careful attention to the system’s kernel compatibility and repository configurations. I recommend enabling the Red Hat Extras repository first, then using the official Docker CE repository to ensure you get the latest stable version. Additionally, verifying that SELinux policies are properly configured will prevent common permission issues during container runtime.

    Rajiv Patel (Linux Systems Architect, OpenSource Innovations). The key to a smooth Docker installation on Redhat 9 lies in pre-installation system updates and dependency checks. Redhat 9’s default package manager, DNF, simplifies the process, but it’s essential to disable conflicting container tools like Podman if Docker is preferred. Post-installation, configuring user groups to allow non-root Docker usage enhances security and usability.

    Lisa Chen (Containerization Specialist, TechForward Consulting). When installing Docker on Redhat 9, leveraging the official Docker installation scripts can streamline the process, but manual installation offers greater control over versions and configurations. It’s critical to test Docker’s networking and storage drivers after installation to ensure compatibility with Redhat 9’s updated kernel and system libraries, especially for production environments.

    Frequently Asked Questions (FAQs)

    What are the prerequisites for installing Docker on Red Hat Enterprise Linux 9?
    Ensure your system is registered with Red Hat Subscription Manager, has an active internet connection, and that you have root or sudo privileges. Additionally, disable any conflicting container tools before proceeding.

    How do I enable the Docker repository on Red Hat 9?
    You can enable the Docker repository by adding the official Docker CE repository using the `dnf config-manager` command or by manually creating a repository file under `/etc/yum.repos.d/` with the appropriate Docker CE repository configuration.

    Which command installs Docker Engine on Red Hat 9?
    Use the command `sudo dnf install docker-ce docker-ce-cli containerd.io` to install Docker Engine and its components on Red Hat 9.

    How do I start and enable the Docker service after installation?
    Run `sudo systemctl start docker` to start the Docker daemon and `sudo systemctl enable docker` to configure it to start automatically at boot.

    How can I verify that Docker is installed and running correctly on Red Hat 9?
    Execute `sudo docker run hello-world`. If Docker is installed and running properly, this command will download and run a test container that outputs a confirmation message.

    Are there any SELinux considerations when installing Docker on Red Hat 9?
    Yes, ensure that SELinux policies are compatible with Docker. By default, SELinux is enabled in enforcing mode on Red Hat 9, and Docker supports it, but custom policies or misconfigurations may require adjustments.
    Installing Docker on Red Hat Enterprise Linux 9 involves a series of well-defined steps that ensure a smooth setup and optimal performance. The process begins with preparing the system by updating existing packages and enabling the necessary repositories. Following this, the Docker CE (Community Edition) packages are installed using the DNF package manager, which is the default for RHEL 9. Proper configuration, including starting and enabling the Docker service, is crucial to ensure Docker runs seamlessly on system boot.

    Key considerations during the installation include managing user permissions by adding users to the Docker group, which facilitates running Docker commands without elevated privileges. Additionally, understanding the differences between Docker CE and the container tools provided natively by RHEL 9 helps in making informed decisions based on specific use cases and enterprise requirements. Ensuring that the system firewall and SELinux policies are appropriately configured can prevent common issues related to container networking and security.

    In summary, installing Docker on Red Hat 9 is a straightforward process when following best practices and official guidelines. This setup empowers users to leverage containerization for application development, deployment, and management effectively. Adhering to these steps not only guarantees a reliable Docker environment but also aligns with Red Hat’s security and stability standards, making it suitable

    Author Profile

    Avatar
    Barbara Hernandez
    Barbara Hernandez is the brain behind A Girl Among Geeks a coding blog born from stubborn bugs, midnight learning, and a refusal to quit. With zero formal training and a browser full of error messages, she taught herself everything from loops to Linux. Her mission? Make tech less intimidating, one real answer at a time.

    Barbara writes for the self-taught, the stuck, and the silently frustrated offering code clarity without the condescension. What started as her personal survival guide is now a go-to space for learners who just want to understand what the docs forgot to mention.