在Ubuntu 14.04上运行没有sudo的docker [英] Running docker without sudo on Ubuntu 14.04
问题描述
我尝试设置Docker,以便在使用它之前不必键入sudo
.
I attempted to set up Docker so that I do not have to type sudo
before using it.
我采取的步骤:
- 我首先使用
sudo groupadd docker
创建一个docker组; - 我通过
sudo gpasswd -a ${USER} docker
将当前用户添加到"docker"组; - 我用
sudo service docker restart
重新启动了docker; - 我关闭并打开终端以开始新的会话.
- I started with creating a docker group with
sudo groupadd docker
; - I added my current user to the "docker" group with
sudo gpasswd -a ${USER} docker
; - I restarted docker with
sudo service docker restart
; - I closed and opened the terminal to start a new session.
运行docker run hello-world
后,我收到以下输出:
After running docker run hello-world
, I receive this output:
FATA [0000]发表 http:///var/run/docker .sock/v1.17/containers/create :拨打Unix/var/run/docker.sock:权限被拒绝.您是否要连接到没有TLS的启用TLS的守护程序?
FATA[0000] Post http:///var/run/docker.sock/v1.17/containers/create: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?
令人困惑的一件事(可能会提示为什么我必须在没有sudo的情况下才能运行docker):
One thing that puzzles (and might give a hint about why I cannot run docker without sudo) is the output of:
$ groups
:是:
ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare
ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare
(没有"docker"组)
(no "docker" group)
$ groups ltarasiewicz
的输出:
ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare docker
ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare docker
(码头工人"是其中一员)
("docker" is one of the groups)
将我的当前用户添加到"docker"组后,仍然无法使用sudo
的Docker的原因可能是什么?
What might be the reason for the fact that I still cannot use Docker withou sudo
after adding my current user to the "docker" group?
推荐答案
组更改不会在当前登录的会话中立即生效.您的选择包括:
Group changes don't take effect immediately in the currently logged in session. Your options include:
- 注销然后重新登录
- 开始新的登录会话(对于bash,这是通过
bash -l
命令进行的操作)
- Log out then log back in
- Start a new login session (for bash this is with the
bash -l
command)
这篇关于在Ubuntu 14.04上运行没有sudo的docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!