Skip to main content
Back to Blog
DevOpsSystem AdministrationCloud Computing
13 August 20266 min readUpdated 13 August 2026

Installing and Using Docker on Rocky Linux

Introduction Docker is a tool designed to simplify the process of running applications in isolated containers. These containers are akin to lightweight environments that bundle...

Installing and Using Docker on Rocky Linux

Introduction

Docker is a tool designed to simplify the process of running applications in isolated containers. These containers are akin to lightweight environments that bundle an application with all its dependencies, making them more efficient than traditional virtual machines which require separate operating system instances. Containers leverage the host system's kernel, allowing for greater portability and resource efficiency.

For a comprehensive overview of Docker's components, one might explore resources focused on the Docker Ecosystem. This guide will walk through the installation and usage of Docker Engine on Rocky Linux, exploring its advantages, how to configure permissions, and its compatibility with multi-container applications using Docker Compose. We'll also cover creating custom images and distributing them via Docker Hub.

Key Takeaways:

  • Rocky Linux and Docker: Although Rocky Linux defaults to using Podman, Docker remains widely used due to its robust ecosystem and compatibility with third-party tools.
  • Installation Tips: It's recommended to install Docker from the official repository to ensure access to the latest version. Rocky Linux, being compatible with Red Hat Enterprise Linux, can use the RHEL-compatible Docker repositories.
  • Docker Group Security: Membership in the Docker group grants extensive system privileges. This group should be reserved for trusted users only, as it allows actions comparable to root access.
  • Architecture: Docker operates with a daemon-based architecture, while Podman is daemonless. Understanding these differences can guide the choice between the two.
  • Docker Compose: Now integrated as a plugin, it facilitates the management of applications composed of multiple containers.

Illustration for: - Rocky Linux and Docker: Alth...

Prerequisites

Before proceeding, ensure your Rocky Linux server is set up with a non-root user having sudo privileges. Follow the initial setup guides to configure your user environment properly.

Docker vs Podman: Why Choose Docker?

Rocky Linux includes Podman as its default container runtime, reflecting a shift in container management strategies focused on security and simplicity. Podman eliminates the need for a root-privileged daemon, contrasting with Docker's client-server model where a central daemon handles all container management. Despite these differences, both can run OCI-compliant containers.

Key Differences

  • Architecture: Docker's client-server model employs a daemon (dockerd) to manage containers, while Podman directly runs containers as child processes.
  • Security: Podman supports rootless containers by default, enhancing security. Docker can be configured for rootless operation but requires additional setup.
  • Ecosystem and Tooling: Docker is supported by a broad ecosystem, including Docker Hub, Docker Compose, and numerous third-party tools, which may not fully support Podman yet.
  • Compatibility: Docker's well-documented API and mature tools make it a preferred choice in many environments.

Illustration for: - Architecture: Docker's clien...

Why Use Docker Instead of Podman?

Docker might be preferred if:

  • Your workflows depend heavily on Docker Compose and other Docker-specific tools.
  • You require features like Docker Swarm, BuildKit, or Docker Content Trust.
  • Comprehensive documentation and community support are essential to your operations.

Step 1 — Installing Docker

To ensure you have the latest version of Docker, it's advisable to install it from the official Docker repository. Here's how:

  1. Update Package Database:

    sudo dnf check-update
    
  2. Install Repository Management Tools:

    sudo dnf install -y dnf-plugins-core
    
  3. Add Docker Repository:

    sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
    
  4. Install Docker and Components:

    sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
  5. Start Docker Service:

    sudo systemctl start docker
    
  6. Enable Docker on Boot:

    sudo systemctl enable docker
    

Step 2 — Running Docker Commands Without Sudo (Optional)

By default, Docker commands require sudo due to the Docker daemon's root-level operations. To avoid this, you can add your user to the Docker group:

sudo usermod -aG docker $(whoami)

Log out and log back in for the changes to take effect. Remember, this grants extensive privileges, so only trusted users should be added.

Understanding Docker Permissions

The Docker daemon operates with root privileges. Users added to the Docker group can send commands to it via the Unix socket, gaining capabilities similar to root access.

Security Implications

Be cautious when managing Docker group memberships, especially on shared systems. Consider using orchestration tools or rootless alternatives like Podman for enhanced security.

Step 3 — Using the Docker Command

Docker commands are structured as follows:

docker [option] [command] [arguments]

Check available commands with:

docker --help

Step 4 — Working with Docker Images

Docker images are the foundation of containers. They are typically pulled from Docker Hub. To verify access to Docker Hub, run:

docker run hello-world

This confirms your Docker setup is correctly functioning.

Step 5 — Running a Docker Container

To run a container interactively:

docker run -it rockylinux

This command places you inside the container's shell.

Step 6 — Using Docker Compose

Docker Compose manages applications with multiple containers. Define your services in a docker-compose.yml file and start them with:

docker compose up -d

This command sets up the necessary environment and starts your services.

Step 7 — Committing Container Changes

To save modifications made in a container to a new image, use:

docker commit -m "Description" -a "Author" container-id new_image_name

Step 8 — Listing Docker Containers

To list all containers, use:

docker ps -a

Step 9 — Pushing Images to Docker Hub

To share images, push them to Docker Hub:

  1. Login with:

    docker login -u username
    
  2. Push the image:

    docker push username/image-name
    

Conclusion

This guide covered the essentials of installing and using Docker on Rocky Linux, including working with containers, images, and Docker Compose. These foundational skills are crucial for managing containerized applications and integrating Docker into various workflows.