How to Install Docker on CentOS?
🔍 Introduction: Why Use Docker on RHEL/CentOS?
Docker has changed how modern applications are built, shipped, and run. It’s the standard for containerized deployment in today’s cloud-native world. Using Docker, developers and system administrators can package apps and their dependencies into lightweight, portable containers that work consistently across systems.
In this guide, we’ll cover:
✅ Installing Docker on CentOS 8/7 or RHEL 8/7
✅ Pulling and running containers from Docker Hub
✅ Managing images and containers via the Docker CLI
✅ Basic container lifecycle commands every user should know
Whether you’re building microservices, managing legacy monoliths, or preparing for Kubernetes, Docker is a must-know.
✅ What is Docker?
Docker is an open-source containerization engine that enables you to run applications in isolated environments called containers. Unlike traditional VMs, Docker containers share the host OS kernel, making them more efficient and faster to spin up.
Key benefits of Docker:
-
📦 Package once, run anywhere
-
🔁 Consistent across dev, test, and prod
-
⚡ Lightweight and fast to deploy
-
🧱 Great for microservices and CI/CD pipelines
📥 Step 1: Installing Docker on CentOS/RHEL 8/7
Follow these steps to install Docker CE (Community Edition) on your system.
🔧 1. Remove Old Docker Versions
Uninstall conflicting packages or legacy Docker versions:
🧰 2. Add Docker Repository
Install required tools and add the Docker official repo:
📦 3. Install Docker Engine (Latest Stable)
🛡️ Note: If prompted, verify the Docker GPG key:060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
▶️ 4. Enable and Start Docker
Check service status:
🧪 Step 2: Verify Docker Installation
Test with Docker’s official hello-world image:
✅ Output Should Be:
🛠️ Step 3: Docker CLI Basics – Version, Help & Info
Use these to learn about your Docker environment:
These are foundational for navigating the Docker CLI as a beginner.
📤 Step 4: Download and Manage Docker Images
Docker Hub is the default registry from which you can pull images.
🔍 Search for Available Images
📥 Download an Image
📋 View Downloaded Images
🗑️ Delete an Image
🧩 Step 5: Run and Manage Docker Containers
Now let’s explore container lifecycle commands.
▶️ Run a Simple Container
Run with a custom name:
📋 View Running & Stopped Containers
⏯️ Start/Stop Containers
❌ Delete a Container
🖥️ Step 6: Access Container Shell (Interactive Terminal)
To interact with a container’s shell:
-
-i
: Keep STDIN open -
-t
: Allocate a pseudo-TTY -
bash
: Command to run the interactive shell
❎ Exit Safely
🔄 Detach Without Killing
Press:
🔁 Reconnect Later
🔪 Force Stop a Container
📊 Bonus Docker Commands for Monitoring
📈 Live Stats of Containers
🧠 View Processes Inside a Container
📌 Pro Tip: Use Docker Compose for Multi-Container Apps
If you’re working with multiple services (like NGINX + MySQL), Docker Compose allows you to define and run them using a single YAML file. It’s great for staging full-stack apps.
❓ Frequently Asked Questions (FAQs)
🔹 Can I install Docker on CentOS Stream?
Yes, Docker works on CentOS Stream. Follow the same steps as CentOS 8.
🔹 Is Podman a replacement for Docker on RHEL?
Podman is Red Hat’s default container engine, but Docker is still widely used and supported.
🔹 Does Docker require a GUI?
No, Docker is fully CLI-driven and works in headless/server environments.
🔹 What’s the difference between Docker CE and EE?
CE (Community Edition) is free and open-source, while EE (Enterprise Edition) includes extra security, support, and management features for enterprise needs.
🎯 Conclusion: You’re Now Docker-Ready on CentOS/RHEL
With Docker installed and running on your CentOS or RHEL 8/7 system, you’re now equipped to build, test, and ship containerized apps with confidence. From running a basic Ubuntu container to understanding container lifecycle commands, you’ve taken your first real step into modern DevOps.
🛠️ Keep exploring:
-
Learn how to build custom Docker images with Dockerfiles
-
Use Docker volumes for data persistence
-
Set up multi-container systems with Docker Compose
-
Automate workflows using CI/CD with containers