How to Install Docker on CentOS 7 & RHEL 7

How to Install Docker on CentOS 7 & RHEL 7

How to Install Docker on CentOS 7 & RHEL 7

1. Update Your System

Before installing Docker, it's essential to update your system to ensure all existing packages are up to date:

sudo yum update -y

2. Uninstall Old Versions of Docker

If you have any older versions of Docker installed, remove them to avoid conflicts:

sudo yum remove docker \ docker-common \ docker-selinux \ docker-engine

3. Install Required Dependencies

Ensure that the yum-utils package is installed, which provides the yum-config-manager utility:

sudo yum install -y yum-utils

4. Set Up the Docker Repository

Add the official Docker repository to your system:phoenixNAP | Global IT Services+1DigitalOcean+1

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

5. Install Docker Engine

Install the Docker Engine package:

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

6. Start and Enable Docker

Start the Docker service and enable it to start on boot:Docker Documentation

sudo systemctl start docker sudo systemctl enable docker

7. Verify Docker Installation

To verify that Docker is installed correctly, run the following command:

sudo docker run hello-world

This command downloads a test image and runs it in a container. If Docker is installed correctly, it will print a confirmation message.Docker Documentation

8. (Optional) Run Docker Commands Without sudo

By default, Docker commands require root privileges. To run Docker commands as a non-root user:

  1. Create the docker group if it doesn't exist:Docker Documentation+1DigitalOcean+1

    sudo groupadd docker

  1. Add your user to the docker group:DigitalOcean

    sudo usermod -aG docker $USER

  1. Log out and log back in to apply the group membership.

Note: These instructions are based on the official Docker documentation for CentOS 7.

Souy Soeng

Souy Soeng

Hi there šŸ‘‹, I’m Soeng Souy (StarCode Kh)
-------------------------------------------
🌱 I’m currently creating a sample Laravel and React Vue Livewire
šŸ‘Æ I’m looking to collaborate on open-source PHP & JavaScript projects
šŸ’¬ Ask me about Laravel, MySQL, or Flutter
⚡ Fun fact: I love turning ☕️ into code!

Post a Comment

CAN FEEDBACK
close