CentOSRHEL Based

How To Install Docker on CentOS Stream 9

Install Docker on CentOS Stream 9

In this tutorial, we will show you how to install Docker on CentOS Stream 9. Docker, the popular containerization platform, has revolutionized the way software is developed, shipped, and deployed. With the ability to package applications and their dependencies into containers, it enables consistent and scalable environments, making it a favorite among developers and system administrators. CentOS Stream 9, a robust Linux distribution, provides a stable foundation for running Docker containers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Docker containers on CentOS Stream 9.

Prerequisites

  • A server running one of the following operating systems: CentOS Stream 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection.
  • You’ll need administrative privileges or root access on your CentOS Stream 9 system. If you don’t have them, reach out to your system administrator.

Install Docker on CentOS Stream 9

Step 1. Maintaining an up-to-date system is essential to ensure a secure and stable environment for Docker. To update your CentOS Stream 9 system, follow these steps:

sudo dnf clean all
sudo dnf update

Step 2. Installing Docker on CentOS Stream 9.

We will install Docker using the official Docker repository. This method ensures that you get the latest and most stable version of Docker for CentOS Stream 9. First, let’s set up the Docker repository. Open your terminal and run these commands:

sudo dnf install yum-utils
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Now that the repository is set up, you can proceed with the Docker installation:

sudo dnf install docker-ce

Confirm that Docker has been successfully installed and is running smoothly. Check the Docker version by running:

docker --version

Let’s also test Docker by running a simple container:

docker run hello-world

If you see a message indicating that your installation appears to be working correctly, Docker is successfully installed on your CentOS Stream 9 system.

Step 3. Managing Docker.

Now that Docker is installed, let’s explore some basic management tasks. To start and enable the Docker service, execute the following commands:

sudo systemctl start docker
sudo systemctl enable docker

By default, Docker requires root privileges to run. However, you can manage Docker as a non-root user by adding your user to the ‘docker’ group. Execute this command to add your user to the Docker group:

sudo usermod -aG docker your_username

Remember to replace ‘your_username‘ with your actual username.

Step 4. Basic Docker Commands.

Here are some essential Docker commands to get you started. To run a Docker container, use the docker run command followed by the container name. For example:

docker run -it --rm alpine

This will start an Alpine Linux container interactively and remove it once you exit.

To list running containers, run:

docker ps

To list all containers, including stopped ones:

docker ps -a

To stop a running container, use:

docker stop container_name_or_id

To remove a stopped container:

docker rm container_name_or_id

To pull a Docker image from the Docker Hub, use:

docker pull image_name

To list locally available images:

docker images

Remember to explore Docker further and delve into Docker Compose, which enables you to define and run multi-container applications.

Congratulations! You have successfully installed Docker. Thanks for using this tutorial to install Docker containers on CentOS Stream 9. For additional help or useful information, we recommend you check the official Docker website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button