Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python docker-py Connection Refused

I am having trouble accessing docker daemon from a client using docker-py in Python. I started a docker daemon by the command sudo docker -d & and the output was [1] 4894. Then I tried to access the daemon from python using the code that I got from here as root

from docker import Client
cli = Client(base_url='unix://var/run/docker.sock')
cli.containers()

This gave me the error:

requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))

I also tried

cli = Client(base_url='tcp://127.0.0.1:4894') 

but it gave me the same error.

like image 809
JackOrJones Avatar asked Apr 17 '15 15:04

JackOrJones


1 Answers

This seems that the /var/run/docker.sock file has the incorrect permissions. As the docker daemon is started as root the permissions are probably to restrictive.

If you change the permissions to allow other users to access it you should have more success (e.g. o=rwx).

like image 106
extols Avatar answered Oct 12 '22 18:10

extols