6

While I was running

>>> import docker
>>> client = docker.from_env()
>>> client.containers.list()

I encountered the following error

requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

I think it is because docker-py is not able to get access of the docker daemon. So how do I fix this?

Shubham Pandey
  • 83
  • 1
  • 1
  • 5
  • 1
    You add your user to the group set up to run docker? On [arch linux](https://wiki.archlinux.org/index.php/docker#Installation) that would be the `docker` group. – Torxed May 09 '20 at 14:16
  • 1
    You'll have to log back in to pick up the group addition, most likely – erik258 May 09 '20 at 14:17

2 Answers2

10

According to Docker docs you should create a group and attach your user to that group.

Create Group

sudo groupadd docker

Attach User to Group

sudo usermod -aG docker $USER

Reload

su -s ${USER}
Tigran
  • 632
  • 1
  • 5
  • 21
0

Do you have a running docker service? You may need to start it first:

sudo systemctl start docker

or whatever the equivalent is on your system.

Or if you're on RHEL8 and using podman, you can do something like:

podman system service tcp:localhost:8080 --time=0 &
Paul Coccoli
  • 546
  • 1
  • 4
  • 16