Server environment: Ubuntu16.04 / centos7.6.1810, Docker version 18.09.3

1. Log in to the server as user sudo, for example, user domi

2. Before creating a docker user group, check whether the docker group exists in the user group. If the docker group exists, you do not need to create it again

sudo cat /etc/group | grep docker
Copy the code

3. Create a docker group and add the corresponding users to the group (999 is the group ID, you can not specify).

sudo groupadd -g 999 docker
sudo usermod -aG docker domi
Copy the code

4. Check whether the creation is successful

cat /etc/group | grep domi
Copy the code

5. Log out of the current user login state and then log in again for permission to take effect or restart the Docker-daemon

sudo service docker restart   # Ubuntu
sudo systemctl restart docker  # Centos system
Copy the code

6. Confirm that you can directly run the Docker command, execute the Docker command

docker  ps
Copy the code

If the following prompt is displayed, the /var/run/docker.sock permission is required

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.39/info: dial Unix/var/run/docker. The sock: connect: permission denied

sudo chmod a+rw /var/run/docker.sock
Copy the code

PS: Customized development, q&A needs, you can contact QQ: 1762016542