Expected behavior
I have a simple Python script using docker-py to list running containers.
import sys import docker import json import time from docker import Client cli = docker.from_env(assert_hostname=False) containers = cli.containers(quiet=True,all=True)
…
If I run it as root user inside the containers, it worked as expected, however, if I run it as a regular user, it gives “permission denied” error.
Question: does it require root privilege to use docker-py to access Docker daemon?
Actual behavior
File “/usr/local/lib/python2.7/dist-packages/docker/api/container.py”, line 70, in containers
res = self._result(self._get(u, params=params), True)
File “/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py”, line 47, in inner
return f(self, *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/docker/client.py”, line 120, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 487, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 475, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/sessions.py”, line 585, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/requests/adapters.py”, line 453, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, error(13, ‘Permission denied’))