/var/run/docker.sock: permission is denied while dockers are running inside the CGI Python script

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

www-data : www-data sudo docker 

On a machine with www data, I can execute docker commands

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

I get the following error when launching a docker image from a 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 don't see here?

+6
source share
1 answer

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

 sudo usermod -a -G docker $username 

to your desired $ username to add them to the group. You will need to log out and log back in for this to take effect (or restart the service).

Please note that this effectively gives the user full access to your host, so do this with caution.

+13
source

Source: https://habr.com/ru/post/1012743/


All Articles