1080*80 ad

How to Install and Use Docker CE on CentOS 8

Here is a guide on how to install and use Docker CE on a CentOS 8 system. Docker is a powerful platform for developers and system administrators to develop, deploy, and run applications with containers. Containers allow you to package an application with all of its dependencies into a standardized unit for software development.

To begin, ensure you have a CentOS 8 server with root privileges or a user with sudo access, and a stable internet connection.

First, it’s a good practice to remove any old installations of Docker if they exist. This command will uninstall conflicting packages:

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

Now, you need to set up the Docker repository. This allows you to install and update Docker directly from Docker’s official repositories. Install the yum-utils package, which provides utilities for managing yum repositories, and then add the stable Docker repository.

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

With the repository configured, you can install the latest version of Docker Engine – Community, containerd, and Docker CLI.

sudo yum install docker-ce docker-ce-cli containerd.io -y

The -y flag automatically confirms prompts during the installation process.

Once the installation is complete, you need to start the Docker daemon and enable it to launch automatically at boot time.

sudo systemctl start docker
sudo systemctl enable docker

To verify that Docker is running correctly, you can check its status:

sudo systemctl status docker

The output should show active (running).

A simple way to test if Docker is installed properly and can run containers is to execute the hello-world image. This command downloads a test image and runs it in a container.

sudo docker run hello-world

If the installation is successful, you will see a message confirming that your installation appears to be working correctly.

By default, running docker commands requires sudo privileges. To manage Docker as a non-root user, you need to add your user to the docker group. Replace your_user with your actual username.

sudo usermod -aG docker your_user

After adding your user to the group, you need to log out and log back in for the changes to take effect, or run the following command:

newgrp docker

Now you should be able to run docker commands without using sudo. For example:

docker run hello-world

Let’s explore some basic Docker commands.

To search for images in the Docker Hub registry:
docker search image_name

To download an image from Docker Hub:
docker pull image_name

To list downloaded images on your system:
docker images

To list running containers:
docker ps

To list all containers, including stopped ones:
docker ps -a

To run a new container from an image:
docker run image_name (This downloads and runs if not present)

To stop a running container using its ID or name:
docker stop containeridor_name

To remove a stopped container:
docker rm containeridor_name

To remove a downloaded image:
docker rmi imageidor_name

Updating Docker CE is as simple as running a standard system update:
sudo yum update docker-ce

If you ever need to uninstall Docker CE, use the following command:
sudo yum remove docker-ce docker-ce-cli containerd.io
You may also want to remove associated files and directories, which contain images, containers, volumes, and networks.
sudo rm -rf /var/lib/docker

You have now successfully installed and learned the basics of using Docker CE on your CentOS 8 system. You can now start deploying and managing your applications using containers.

Source: https://kifarunix.com/install-and-use-docker-ce-on-centos-8/

900*80 ad

      1080*80 ad