好像默认的只有sudo
有docker相关权限,普通用户docker run hello-world
会有权限报错,解决方法如下
具体错误
如果直接运行
1 | docker run hello-world |
产生错误
1 | docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied.See 'docker run --help'. |
解决方法
创建docker group
1 | sudo groupadd docker |
把当前用户加入docker group
1 | sudo usermod -aG docker $USER |
登出再登入,此时可以直接运行
1 | docker run hello-world |
参考资料
- https://stackoverflow.com/questions/48957195/how-to-fix-docker-got-permission-denied-issue