问题记录:Docker daemon socket权限不足

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.38/containers/create: dial unix /var/run/docker.sock: connect: permission denied.

出现上面问题是因为:

Manage Docker as a non-root user

即:管理Docker的不是root用户

原文表述:

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.

If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

即:docker进程使用Unix Socket而不是TCP端口。而默认情况下,Unix socket属于root用户,需要root权限才能访问。

方案一:使用sudo获取管理员权限,运行docker命令

方案二:添加docker group组,将用户添加进去

songyanyan@songyanyan:~$ sudo group add docker[sudo]songyanyan 的密码: sudo:group:找不到命令songyanyan@songyanyan:~$ sudo groupadd docker#添加docker用户组groupadd:“docker”组已存在songyanyan@songyanyan:~$ sudo gpasswd-a$USERdocker#将登陆用户加入到docker用户组中正在将用户“songyanyan”加入到“docker”组中songyanyan@songyanyan:~$ newgrp docker#更新用户组songyanyan@songyanyan:~$ docker ps#测试当前用户是否可以正常使用docker命令CONTAINERIDIMAGECOMMANDCREATEDSTATUSPORTSNAMESsongyanyan@songyanyan:~$

参考原文链接:https://www.cnblogs.com/informatics/p/8276172.html

你可能感兴趣的:(问题记录:Docker daemon socket权限不足)