How to fix docker: Got permission denied issue

前端 未结 19 977
醉话见心
醉话见心 2020-11-28 00:15

I installed Docker in my machine where I have Ubuntu OS. After than I installed docker, when I run

sudo docker run hello-world

All it\'s ok

相关标签:
19条回答
  • 2020-11-28 00:39

    I solve this error with the command :

    $ sudo chmod 666 /var/run/docker.sock
    
    0 讨论(0)
  • 2020-11-28 00:40

    you can follow these steps and this will work for you:

    1. create a docker group sudo groupadd docker
    2. add your user to this group sudo usermod -aG docker $USER
    3. list the groups to make sure that docker group created successfully by running this command groups
    4. run the following command also to change the session for docker group newgrp docker
    5. change the group ownership for file docker.socksudo chown root:docker /var/run/docker.sock
    6. change the ownership for .docker directory sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
    7. finally sudo chmod g+rwx "$HOME/.docker" -R

    After that test you can run docker ps -a

    0 讨论(0)
  • 2020-11-28 00:41

    A simple hack is to execute as a "Super User".

    To access the super user or root user, follow:

    At user@computer:

    $sudo su
    

    After you enter your password, you'll be at root@computer:

    $docker run hello-world
    
    0 讨论(0)
  • 2020-11-28 00:42

    Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/json: dial unix /var/run/docker.sock: connect: permission denied

    sudo chmod 666 /var/run/docker.sock
    

    This fix my problem.

    0 讨论(0)
  • 2020-11-28 00:43

    To fix that issue, I searched where is my docker and docker-compose installed. In my case, docker was installed in /usr/bin/docker and docker-compose was installed in /usr/local/bin/docker-compose path. Then, I write this in my terminal:

    To docker:

    sudo chmod +x /usr/bin/docker
    

    To docker-compose:

    sudo chmod +x /usr/local/bin/docker-compose
    

    Now I don't need write in my commands docker the word sudo

    /***********************************************************************/

    ERRATA:

    The best solution of this issue was commented by @mkasberg. I quote comment:

    That might work, you might run into issues down the road. Also, it's a security vulnerability. You'd be better off just adding yourself to the docker group, as the docs say. sudo groupadd docker, sudo usermod -aG docker $USER. Docs: https://docs.docker.com/install/linux/linux-postinstall/

    Thanks a lot!

    0 讨论(0)
  • 2020-11-28 00:45

    You can always try Manage Docker as a non-root user paragraph in the https://docs.docker.com/install/linux/linux-postinstall/ docs.

    After doing this also if the problem persists then you can run the following command to solve it:

    sudo chmod 666 /var/run/docker.sock
    
    0 讨论(0)
提交回复
热议问题