1. Solve the docker permission problem
After installing docker, execute docker related commands, and there will be:
”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.26/images/json: dial unix /var/run /docker.sock: connect: permission denied“
cause:
The docker process uses Unix Socket instead of TCP port. By default, the Unix socket belongs to the root user and requires root privileges to access it.
Solution 1:
Use sudo to obtain administrator privileges and run docker commands
Solution 2:
When the docker daemon is started, the user group named docker will be given the permission to read and write Unix socket by default. Therefore, as long as the docker user group is created and the current user is added to the docker user group, the current user has the permission to access the Unix socket , Then you can execute docker related commands
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
docker ps #测试docker命令是否可以使用sudo正常使用