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 a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button