2

I am attempting to install and use docker for the first time. I have followed the guidelines provided in the answer to this question:

sudo groupadd docker

which at this point returns (as expected):

groupadd: group 'docker' already exists

I then attempt to add the user to the group:

sudo usermod -aG docker $wb_s2s

which only returns

Options:
  -b, --badnames                allow bad names
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
...

I then try to log out and lock back in and/or restart the computer/docker (I've tried everything). But when I run:

docker run hello-world

I get an error:

docker: Got permission denied while trying to connect to the Docker daemon socket at ... connect: permission denied. See 'docker run --help'.

Can anyone tell me where I went wrong?

WB_S2S
  • 87
  • 7
  • The easiest way to add a user to a group is `sudo gpasswd -a `. After you run it, make sure to *restart your login* to pick up the new group. Use `groups` command to verify your groups. – erik258 Aug 02 '21 at 23:03

1 Answers1

3

When you add your user to the group, the docs meant literally $USER to refer to your user wb_s2s (which is a variable presented in your shell's environment for purposes like this)

adding $ will make it a variable the shell interprets as an empty string

% echo $USER
ti7
% echo $ti7

% echo $whatever

You could use the $USER variable, or just remove the $ from your attempt to add your user to the group

-sudo usermod -aG docker $wb_s2s
+sudo usermod -aG docker wb_s2s
ti7
  • 16,375
  • 6
  • 40
  • 68