Docker is an open-source platform that automates the deployment, scaling, and management of applications in containers. Containers allow developers to package an application with all its dependencies and deliver it as a single package, which can be deployed on any system that supports containerization. In this tutorial, we will guide you through the process of installing Docker on CentOS Stream 9 and RHEL 9.
- A freshly installed CentOS Stream 9 or RHEL 9 system.
- A user account with sudo privileges.
Step 1: Update the System
Before installing Docker, it is essential to update your system to ensure all the required packages and dependencies are up-to-date. Execute the following command:
sudo dnf update -y
Step 2: Install Required Dependencies
Next, install the necessary dependencies for Docker:
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
Step 3: Add Docker Repository
Now, add the Docker repository to your system. The configuration file is avaialble on Docker’s official site. The CentOS Stream 9 users execute the following command:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
For RHEL 9 users, the command will be:
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
Step 4: Install Docker CE
With the Docker repository in place, you can now install Docker CE (Community Edition) using the following command:
sudo dnf install -y docker-ce --nobest
--nobest flag is used to install the highest version of Docker that satisfies the package’s dependencies.
Step 5: Enable and Start Docker Service
Once the installation is complete, enable the Docker service to start on boot and start the service immediately:
sudo systemctl enable --now docker
Step 6: Verify Docker Installation
To ensure that Docker is installed and running correctly, you can check its status with the following command:
sudo systemctl status docker
Additionally, you can verify the installed version by running:
sudo docker --version
Step 7: Configure Docker to Run Without Sudo (Optional)
By default, Docker requires sudo privileges to execute commands. If you want to run Docker commands without sudo, you can add your user to the “docker” group. Replace “your_username” with your actual username:
sudo usermod -aG docker your_username
Log out and log back in for the changes to take effect. Keep in mind that adding your user to the “docker” group gives the user root-level privileges. Make sure you understand the security implications before performing this step.
You have now successfully installed Docker on your CentOS Stream 9 or RHEL 9 system. You can start deploying and managing containerized applications using the Docker platform. To learn more about Docker and its usage, consult the official Docker documentation at https://docs.docker.com/.