Docker:docker权限设置(二)
docker设置当前非root用户,免sudo操作
docker官网中有说明:
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 preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.
设置步骤:
1、创建docker用户组
$ sudo groupadd docker
2、添加当前用户至docker用户组
$ sudo usermod -aG docker $USER
3、更新用户组权限
$ newgrp docker
4、验证
$ docker run hello-world
需要执行第三步
否则会出现如下问题:
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.40/images/json: dial unix /var/run/docker.sock: connect: permission denied
更多推荐
所有评论(0)