Reference: https://docs.docker.com/engine/install/centos/
Install yum-utils
sudo yum install -y yum-utils
Add docker repo
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install docker engine
sudo yum install -y docker-ce docker-ce-cli containerd.io
Enable docker service
sudo systemctl enable --now docker
Check docker service status
sudo systemctl status docker
Create a docker group (if required)
sudo groupadd docker
Add your personal user to the docker group
sudo usermod -aG docker $USER
Run the following command
newgrp docker
to update group information in the current session. Alternatively, you can simply re-login.
Run a test to confirm docker is working
[roberto@vmlab01 ~]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
...
If you get the following error when ran the previous command:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version”: dial unix /var/run/docker.sock: connect: permission denied
Run the following command:
sudo chgrp docker /var/run/docker.sock
and try again