Do you want to try Docker on your CentOS server? Docker lets you run apps in containers. These containers are fast and clean. You don’t need to install apps the old way. I use Docker a lot for testing and running tools I don’t want to install directly on my system.
In this guide, I’ll walk you through each step. You don’t need to be an expert. Just follow along. I’ll also explain why each step matters.
What Is Docker?
Before we begin, let’s talk about what Docker is.
Docker is a tool that helps you run apps in containers. A container is like a small box that holds an app and everything it needs to run. It doesn’t mess with the rest of your system.
You can:
- Try new tools without installing a lot of stuff
- Keep your server clean
- Run the same app the same way on different systems
I use Docker when I don’t want to break my system or mess up my settings. You might find it useful too.
Why Use Docker on CentOS?
CentOS is a stable Linux system. Many people use it for servers. Docker runs well on it. If you’re running a CentOS VPS or home server, Docker can save you time.
Here are some reasons I use Docker on CentOS:
- I can try apps without installing all their files
- I can run multiple versions of the same app
- It’s easy to start, stop, and clean up containers
Now let’s get Docker installed step by step.
Step 1: Update Your System
Before adding anything new, it’s smart to update your system.
Open your terminal and run:
sudo yum update -y
This will install the latest updates. It helps avoid errors later.
Step 2: Add Docker Repository
CentOS doesn’t come with Docker in its default repo. So you need to add Docker’s official repo.
Run this:
sudo yum install -y yum-utils
Then add the Docker repo:
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
This gives you access to the official Docker packages.
Step 3: Install Docker
Now you can install Docker with this command:
sudo yum install -y docker-ce docker-ce-cli containerd.io
Let it finish. You’ll now have Docker on your system.
Want to check if it’s installed?
docker --version
You should see something like:
Docker version 24.0.2, build cb74dfc
Step 4: Start and Enable Docker
To start Docker right now:
sudo systemctl start docker
To make it start every time your system boots:
sudo systemctl enable docker
Check that it’s running:
sudo systemctl status docker
If it says “active (running),” you’re good to go.
Step 5: Run Docker Without Sudo (Optional)
Right now, you need to use sudo
every time. That’s fine for security, but maybe you want to avoid typing it.
Here’s how to let your user run Docker without sudo:
sudo usermod -aG docker $USER
After that, log out and log back in. Then try:
docker run hello-world
It should run a test container that shows a hello message.
Step 6: Test a Real Docker Image
Want to test Docker with a real app?
Try this:
docker run -d -p 8080:80 nginx
This will pull the NGINX web server image and run it.
Visit your server IP at port 8080. You should see the NGINX welcome page.
You can stop it with:
docker ps
Then:
docker stop [container_id]
What Are the Benefits?
So now you’ve installed Docker. But what are the real benefits?
Here’s what I like:
- I can test apps without installing them on my system
- I can remove apps cleanly without leaving files behind
- I can run apps in isolated containers
- I can use the same image on my laptop or server
This saves me time and stress.
Things You Might Like About Docker
Here’s a quick list of things Docker can help with:
- Testing web apps quickly
- Running databases like MySQL or Redis
- Trying out programming languages
- Spinning up WordPress or other CMS platforms
- Avoiding “dependency hell” (when apps need different versions of the same library)
And here’s when Docker might not be right:
- If you only run one or two apps, and don’t need isolation
- If you’re uncomfortable with command-line tools
- If your system has very low RAM or disk space
A Quick Comparison
Feature | Normal Install | Docker Container |
---|---|---|
Installs system-wide | Yes | No |
Easy to remove | Sometimes | Yes |
Uses lots of space | Often | Less |
Runs in isolation | No | Yes |
Works across systems | Maybe | Yes |
I like that Docker keeps things tidy. If something breaks, I just remove the container and start over.
Helpful Docker Commands
Here are a few commands I use a lot:
docker ps
— shows running containersdocker images
— shows downloaded imagesdocker stop [id]
— stops a containerdocker rm [id]
— removes a containerdocker rmi [image]
— removes an imagedocker logs [id]
— see logs from a container
Final Notes
Docker is a handy tool for running apps. You don’t need to be a Linux pro to use it. If you use CentOS, it works well and installs cleanly.
You learned how to:
- Update your system
- Add the Docker repo
- Install Docker
- Start and enable the service
- Run your first container
Want to try more? You can explore Docker Hub. It has thousands of free apps you can run in seconds.
Have you used Docker before? What apps do you want to try? Let me know — I enjoy sharing what’s worked for me?