To install and set up Docker on RHEL 7 or CentOS 7, you can use the following steps:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
This will install the yum-utils
and device-mapper-persistent-data
packages, which are required to set up the Docker repository.
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
This will add the Docker Community Edition (CE) repository to your system.
sudo yum install docker-ce
This will install the latest version of Docker CE available from the repository.
sudo systemctl enable --now docker
docker
group:sudo usermod -aG docker $USER
This will allow you to run Docker commands without using sudo
.
docker run hello-world
This will run a simple Docker container, which will print a message indicating that Docker is working correctly.