How to Install Docker in CentOS

  1. Update the package index and install the necessary dependencies:
sudo yum update
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

What this line “sudo yum install -y yum-utils device-mapper-persistent-data lvm2” doing:

This command installs the necessary dependencies required by Docker on CentOS. Here’s what each of the packages does:

  • yum-utils: provides utilities and plugins for managing and configuring YUM repositories and packages.
  • device-mapper-persistent-data: provides a persistent metadata store for the device-mapper driver.
  • lvm2: provides the Logical Volume Manager (LVM) which is a device mapper target that provides logical volume management for the Linux kernel.

These packages are needed by Docker to function correctly and efficiently on a CentOS system. The -y flag in the command allows the installation to proceed without requiring the user to manually confirm the installation.

2. Add the Docker repository to your system:

sudo yum-config-manager --add-repo

3. Install the latest version of Docker CE:

sudo yum install docker-ce docker-ce-cli

Keep remember, sometime you may get some trouble while using above command from podman such.

Is case, you can use –allowerasing.

Using --allowerasing can be useful in certain situations, such as when you are trying to remove a package and its dependencies, but some of the dependencies are also used by other packages. By allowing the erasure of dependencies, you can remove the package and its dependencies without causing any issues with other packages on the system. However, it’s important to use this option with caution, as it can potentially remove packages that are still needed by other applications or services on your system

sudo yum install docker-ce docker-ce-cli --allowerasing

4. Start the Docker service and set it to start at boot:

sudo systemctl start docker
sudo systemctl enable docker

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 76 = 78

Related Post