/var/run/docker.sock: permission denied while running docker within Python CGI script

試著忘記壹切 提交于 2019-12-04 18:29:43

问题


I am trying to run Python CGI script inside which I need to run docker image. I am using Docker version 1.6.2. user is "www-data", which is added in docker group.

www-data : www-data sudo docker 

On machine, with www-data I am able to execute docker commands

www-data@mytest:~/html/new$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

I am getting following error while running docker image from Python CGI script:

fatal msg="Get http:///var/run/docker.sock/v1.18/images/json: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?" 

Is there anything I am missing here?


回答1:


Permission denied on a default install indicates you are trying to access the socket from a user other than root or that is not in the docker group. You should be able to run:

sudo usermod -a -G docker $username

on your desired $username to add them to the group. You'll need to logout and back in for this to take effect (use newgrp docker in an existing shell, or restart the daemon if this is an external service accessing docker like your cgi scripts).

Note that doing this effectively gives that user full root access on your host, so do this with care.



来源:https://stackoverflow.com/questions/40877705/var-run-docker-sock-permission-denied-while-running-docker-within-python-cgi-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!