I attempted to set up Docker so that I do not have to type sudo
before using it.
The steps that I took:
sudo groupadd docker
;sudo gpasswd -a ${USER} docker
;sudo service docker restart
;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?
If you're running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect. Verify that you can run docker commands without sudo . This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
Running the container as root brings a lot of risks. Although being root inside the container is not the same as root on the host machine (some more details here) and you're able to deny a lot of capabilities during container startup, it is still the recommended approach to avoid being root .
Run the following command at the end to apply group settings:
newgrp docker
Group changes don't take effect immediately in the currently logged in session. Your options include:
bash -l
command)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With