Running docker without sudo on Ubuntu 14.04 [close

2019-04-18 05:33发布

问题:

I attempted to set up Docker so that I do not have to type sudo before using it.

The steps that I took:

  1. I started with creating a docker group with sudo groupadd docker;
  2. I added my current user to the "docker" group with sudo gpasswd -a ${USER} docker;
  3. I restarted docker with sudo service docker restart;
  4. I closed and opened the terminal to start a new session.

After running docker run hello-world, I receive this output:

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?

One thing that puzzles (and might give a hint about why I cannot run docker without sudo) is the output of:

$ groups: is:

ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare

(no "docker" group)

The output of $ groups ltarasiewicz:

ltarasiewicz adm cdrom sudo dip plugdev lpadmin sambashare docker

("docker" is one of the groups)

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?

回答1:

Group changes don't take effect immediately in the currently logged in session. Your options include:

  1. Log out then log back in
  2. Start a new login session (for bash this is with the bash -l command)


回答2:

Run the following command at the end to apply group settings:

newgrp docker


回答3:

Closing terminal or logging out wasn't enough in my case, I had to do a complete reboot.