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.

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

See original GitHub issue

I am getting an error when trying to use dockerpty. Using the example in the README:

import docker
import dockerpty

client = docker.Client()
container = client.create_container(
    'busybox:latest',
    stdin_open=True,
    tty=True,
    command='/bin/sh')

dockerpty.start(client, container)

When I run this, I get the error:

Traceback (most recent call last):
  File "test_script.py", line 9, in <module>
    command='/bin/sh')
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/docker/api/container.py", line 116, in create_container
    return self.create_container_from_config(config, name)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/docker/api/container.py", line 126, in create_container_from_config
    res = self._post_json(u, data=config, params=params)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/docker/client.py", line 166, in _post_json
    return self._post(url, data=json.dumps(data2), **kwargs)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/docker/client.py", line 107, in _post
    return self.post(url, **self._set_request_timeout(kwargs))
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 508, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Users/michaelbarton/Library/Python/2.7/lib/python/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(2, 'No such file or directory'))

Here are the details of my docker install, using docker-machine:

Client:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.9.0
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   76d6bc9
 Built:        Tue Nov  3 19:20:09 UTC 2015
 OS/Arch:      linux/amd64

And the details of my OS:

Darwin Michaels-MacBook-Air.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 i386 MacBookAir7,2 Darwin

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
aanandcommented, Jul 29, 2016

If you’re using Docker Machine, you can point docker-py at it using docker-machine env and the kwargs_from_env() utility method.

from docker import Client
from docker.utils import kwargs_from_env

client = Client(**kwargs_from_env(assert_hostname=False))
...
$ eval "$(docker-machine env default)"
$ python script.py
0reactions
rrmerugucommented, Jul 29, 2016

@michaelbarton @mejamiewilson Did you find any solution ? I understand that eval ${docker-machine env default} works great for command, but any solution for Client() via script ?

OS info: Darwin Ravis-MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Read more comments on GitHub >

github_iconTop Results From Across the Web

('Connection aborted.', error(2, 'No such file or directory ...
The error here means that /run/docker.sock doesn't exist. 5
Read more >
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 >
How to use the urllib3.exceptions.ProtocolError function ... - Snyk
To help you get started, we've selected a few urllib3.exceptions. ... if a1 == 2 or a2 == "No such file or directory":...
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