Voxfor - All rights reserved - 2013-2025
We Accepted





This guide provides complete instructions to install Docker on CentOS Stream. Docker is a powerful tool for containerizing applications, allowing developers to package their code and dependencies in a single
If you still need to get Docker installed on CentOS Stream 9, you’re in the right place. In this guide, you’re going to learn how to set up repositories, configure Docker, and deal with common problems in the process.
If you still need to set up your CentOS Stream 9 system before installing Docker, you need to do that first.
Docker requires a 64-bit CentOS system. As a minimum, 2 GB RAM is enough, though 4 GB RAM is highly recommended if you’re planning to run many containers.
Make sure that you have root or sudo privileges on the system, as installing and managing Docker requires administrative permissions.
To avoid conflicts while setting up Docker, we first update all available packages to their latest.
sudo dnf update -y
Install the dnf-plugins-core package to enable additional DNF features for managing repositories:
sudo dnf install -y dnf-plugins-core
With these prerequisites met, you’re ready to install Docker on CentOS Stream 9.
Installing Docker on CentOS Stream, the official Docker repository, would be the best source because that assures that you are getting the latest and most compatible Docker versions.
To begin, add the official Docker repository to your system’s sources. It will allow your package manager to pull Docker CE (Community Edition) and its dependencies directly from the trusted source of Docker and then install them on your machine:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
This command configures DNF to recognize Docker’s repository, making future Docker installations and updates.
Once the repository is configured, proceed to install Docker CE along with important components like Docker CLI and containerd. Execute the following command:
sudo dnf install docker-ce docker-ce-cli containerd.io -y
The -y flag makes sure the installation proceeds without needing user confirmation, saving time. This step is for featuring the core functionality of Docker on your CentOS System, aka containers management and creation.
After installation, start the Docker service using systemctl:
sudo systemctl start docker
The Docker daemon is started, and containerized applications in Docker can be run when Docker is started. After this step, it’s a good idea to check if Docker runs easily.
To make sure Docker starts automatically after a system reboot, enable the Docker service:
sudo systemctl enable docker
It’s especially useful for production, which requires consistent availability. With this command, the Docker would start by itself whenever you reboot the computer, So it means you will no longer have to start Docker manually.
Check that Docker has been installed successfully by displaying its version:
sudo docker --version
If no errors appear, this command displays Docker’s version number and is successful if it displays. Additionally, you can also run sudo docker and hello-world to see if the Docker works by running just a simple container.
You can set up Docker through the repository of Docker’s official repository if you do not want to add it to Docker’s repository. It offers us an alternative that is another Docker source, and it can work for us on CentOS Stream.
The CentOS Stream Extras repository may already be enabled, but if not, install it with:
sudo dnf config-manager --set-enabled crb
The crb (CodeReady Builder) repository contains additional packages needed for building and deploying applications on CentOS Stream.
Install Docker using the CentOS Extras repository:
sudo dnf install -y docker
With -y automatically does the installation, so it’s easier. This command will install Docker CE the way it’s meant to be used, making your system all set for all container operations.
After installation, activate Docker:
sudo systemctl start docker
For running a container and using Docker’s feature, it is important to start the Docker. Check that Docker is running OK.
Set Docker to start automatically on system boot:
sudo systemctl enable docker
This process is a critical step for continuous availability environments, this command tells Docker also to start up when you reboot.
Run a test Docker container to confirm successful installation:
sudo docker run hello-world
For additional verification, run a test container using sudo docker and run hello-world to confirm Docker is fully functional. This process confirms that Docker can pull and run images without issues.
If you see the message from the hello-world container, Docker is working correctly.
This process is a critical step for continuous availability environments, this command tells Docker also to start up when you reboot.
To allow non-root users to run Docker without the sudo command, add your user to the Docker group.
sudo usermod -aG docker $USER
Log out and back in for the new permissions to take effect.
Make sure Docker is configured to start on boot:
sudo systemctl enable docker
Verify Docker works without requiring sudo by running:
docker run hello-world
If the hello-world message displays, Docker is set up correctly for non-root access.
Docker’s storage configuration can be customized to improve performance or manage storage on different disks.
Docker stores data by default in
/var/lib/docker
The overlay2 storage driver is recommended for performance. To confirm or configure it, add it to Docker’s daemon configuration file.
To change Docker’s storage path, open or create the Docker daemon configuration file:
sudo nano /etc/docker/daemon.json
Add the following configuration:
{
"data-root": "/new/docker/path"
}
Replace /new/docker/path with your preferred storage path.
To apply the changes, restart Docker:
sudo systemctl restart docker
The Docker daemon can be configured to suit different requirements.
Edit the Docker daemon configuration file:
sudo nano /etc/docker/daemon.json
To pull images from private or local registries, add them to the daemon file:
{
"insecure-registries": ["your_registry_domain.com:5000"]
}
Set up logging options to limit log sizes and improve performance:
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
Apply your changes by restarting Docker:
sudo systemctl restart docker
Here are some key Docker commands for managing containers and images.
Pull an image from Docker Hub:
sudo docker pull nginx
Run a container in detached mode:
sudo docker run -d --name my-nginx -p 80:80 nginx
To view active containers and available images:
sudo docker ps
sudo docker images
Stop and remove containers when they’re no longer needed:
sudo docker stop my-nginx
sudo docker rm my-nginx
Follow these steps to update or uninstall Docker on CentOS Stream 9.
Update Docker to the latest version:
sudo dnf check-update
sudo dnf update docker-ce docker-ce-cli containerd.io
If you need to remove Docker:
sudo dnf remove docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
Here are solutions to common Docker installation issues.
Check Docker logs for more details:
sudo journalctl -u docker
Make sure Docker is running and check permissions:
sudo systemctl start docker
sudo systemctl enable docker
Make sure Docker’s ports are open by configuring the firewall:
sudo firewall-cmd --zone=public --add-masquerade --permanent
sudo firewall-cmd --reload
If containers experience network problems, reset Docker network settings:
sudo systemctl restart docker
Congrats, you’ve already installed Docker on CentOS Stream 9, and got it running in top shape. Docker makes it possible to bring the app code, dependencies, and environment into containers and keep everything consistent across environments. Now you are ready to dive into Docker’s more complex features, which include such as docker-compose and container orchestration.
Vinayak Baranwal wroteย this article.ย Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.
James
Great guide on Docker installation for CentOS Stream 9! I really appreciated the detailed steps and options for installing Docker from both the official Docker repository and CentOS Stream Extras. The post-installation section, especially how to run Docker without sudo, is incredibly helpful. Perfect for anyone looking to get Docker up and running smoothly on CentOS!
Robert Davis
This step-by-step guide provides clear instructions for installing and configuring Docker on CentOS Stream 9, with comprehensive explanations of each process. It ensures users can set up Docker efficiently, troubleshoot common issues, and make the most of Docker’s advanced features for container management.