skip to Main Content

I was just getting started with docker, and I run this:

docker pull redis  

and I get a permission denied error. It turns out, docker writes to /var/* directories, which requires permission to write. and so many other docker commands also require something like:

sudo docker ***    

Now, I don’t really like the notion of add root privileges to every docker command.(It might be because I just don’t know docker much yet, but that’s true with every program). Is this a requirement by docker?

If it is not required, then how do I configure it so that it is much like other programs, that only ask me privileges when they need to, all the pulling, running commands would just write to my normal directories or run from them, not from a system directory.

EDIT: my concern was, if docker was allowed access to system files, meaning, it has some embedded scipt that had a potential harm to the computer, and it executed when I ran the docker. Since, I give it root privileges, the script could do anything. Would adding it to the user group instead of sudo fix that?

2

Answers


  1. By default Docker runs an always-on daemon on your system which requires root privileges (Experimental non-root Docker support exists though).

    The common approach is to add your User to the docker group which allows you to run docker without having to sudo: https://docs.docker.com/engine/install/linux-postinstall/

    sudo usermod -aG docker $USER
    newgrp docker 
    

    If you are interested in non-root Docker the following might be interesting:

    Login or Signup to reply.
  2. You are not probably part of docker group as user. You could try post-installations steps mentioned on here.

    Create group docker:

     sudo groupadd docker
    

    Add user to the group

    sudo usermod -aG docker $USER
    

    Reload changes:

     newgrp docker 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search