Solution to Docker command error: Got permission denied while trying to connect to the Docker daemon socket at unix:/

        After installing docker, when running the command, the following error message appears:

   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. Means trying to connect unix:///var/run/docker.sock:, but insufficient permissions.

        As shown below:

         Cause Analysis: This is because your current user does not have this permission. By default, the docker command will  Unix socket communicate with the Docker engine. Only the root user and users of the docker group can access the Docker engine  Unix socket. For security reasons, users are not used directly on Linux systems  root . That is, our current user is not the root user.

        Solution: Just add our current users to the docker group, so that they are a family.

The first step: sudo gpasswd -a username docker   #Add the common user username to the docker group, and the username field can also be directly replaced with $USER.

Step 2: newgrp docker  #Update docker group

Step 3: Execute the command that you reported the error again, and the error will not be reported at this time.

Guess you like

Origin blog.csdn.net/BaoITcore/article/details/127736052