question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ConnectionError: ('Connection aborted.', error(2, 'No such file or directory'))

See original GitHub issue

Attempting to spawn a docker container from within a docker container using docker-py.

OS X, dockerpy-1.10.6

Here is my code (select_device is a simple, known-good function)

docker_client = docker.from_env()
worker = docker_client.create_container("worker",
                                    environment={'DEVICE':select_device(priority),
                                        'GIT_REPO':git_repo, 'TASK_ID':delegate.request.id})

Here is the trace:

delegation_1  | [2016-12-05 07:39:41,079: INFO/MainProcess] Received task: delegate[e28262d3-1862-456c-ba43-013114fc7dbf]
delegation_1  | [2016-12-05 07:39:43,095: ERROR/PoolWorker-3] Task delegate[e28262d3-1862-456c-ba43-013114fc7dbf] raised unexpected: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)
delegation_1  | Traceback (most recent call last):
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 368, in trace_task
delegation_1  |     R = retval = fun(*args, **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 623, in __protected_call__
delegation_1  |     return self.run(*args, **kwargs)
delegation_1  |   File "/opt/app/delegate.py", line 45, in delegate
delegation_1  |     'GIT_REPO':git_repo, 'TASK_ID':delegate.request.id})
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 135, in create_container
delegation_1  |     return self.create_container_from_config(config, name)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 145, in create_container_from_config
delegation_1  |     res = self._post_json(u, data=config, params=params)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 198, in _post_json
delegation_1  |     return self._post(url, data=json.dumps(data2), **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 47, in inner
delegation_1  |     return f(self, *args, **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/docker/client.py", line 135, in _post
delegation_1  |     return self.post(url, **self._set_request_timeout(kwargs))
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 535, in post
delegation_1  |     return self.request('POST', url, data=data, json=json, **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in request
delegation_1  |     resp = self.send(prep, **send_kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 609, in send
delegation_1  |     r = adapter.send(request, **kwargs)
delegation_1  |   File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 473, in send
delegation_1  |     raise ConnectionError(err, request=request)
delegation_1  | ConnectionError: ('Connection aborted.', error(2, 'No such file or directory'))

Am I crazy in thinking I can run docker-py from within a docker container?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
hkalinacommented, Feb 15, 2021

If you get No such file or directory, check the docker service is running: sudo systemctl start docker

If you get Permission denied, make sure your user is added into the “docker” group: sudo usermod -aG docker ${USER}

5reactions
TomasTomecekcommented, Dec 5, 2016

Am I crazy in thinking

No, you’re not. But you have to bind-mount docker socket (if that’s how you access docker daemon) inside the container. Then you’re fine.

The error here means that /run/docker.sock doesn’t exist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

requests.exceptions.ConnectionError: ('Connection aborted ...
I believe you might be running the container that might be connecting another service(DB access or other container service) that was only ...
Read more >
error while fetching server api version: ('connection aborted ...
I've found solution is Docker daemon is not working after Docker was installed by Ansible . It's required to add following command in...
Read more >
Error saying ConnectionError ProtocolError Connection ...
I have a private insecure docker registry running at http://registry.myserver.com:5000. Ansible version: 1. ... (2, 'No such file or ...
Read more >
Server setup docker install error - Questions - n8n community
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory')).
Read more >
"Command Failed" Error When Starting the Ansible Container
This occurs when the Docker Engine is not running on a node. To resolve this issue: Ensure that the Docker Engine is running...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found