Docker 权限更新
2020-01-20 本文已影响0人
semiscone
Docker默认权限
Docker安装后默认需要sudo执行,否则有以下错误:
william@nio:~$ docker ps
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/containers/json: dial unix /var/run/docker.sock: connect: permission denied
可以执行以下步骤更新权限
william@nio:~$ sudo groupadd docker
groupadd: group 'docker' already exists
william@nio:~$ sudo gpasswd -a $USER docker
Adding user william to group docker
william@nio:~$ newgrp docker
william@nio:~$
执行docker命令不在需要 sudo 权限
william@nio:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
william@nio:~$