Code Monkey home page Code Monkey logo

Comments (9)

tlbtlbtlb avatar tlbtlbtlb commented on September 7, 2024

Perhaps you have $DOCKER_HOST set in your environment? When using Docker for Mac, it's better to unset it. (It was necessary with docker-machine, but not Docker for Mac.)

from universe-starter-agent.

gpunti avatar gpunti commented on September 7, 2024

I have no $DOCKER_HOST. I have no idea why it tries to connect to 192.168.59.103. No file in my /etc directory ( and recursive ) configures any 192.168.59.103. It's the default address when using boot2docker: https://github.com/boot2docker/boot2docker . I'm using Docker version 1.13.0, build 49bf474.

from universe-starter-agent.

tlbtlbtlb avatar tlbtlbtlb commented on September 7, 2024

I'd like to track this down. We use docker-py to connect to the docker daemon, which may do something complicated in different environments. Can you try this interactively:

$ python
>>> import universe.remotes.docker_remote
>>> client,info = universe.remotes.docker_remote.get_client()
>>> client.base_url
'http+docker://localunixsocket'
>>> import docker
>>> client2 = docker.Client()
>>> client2.base_url
'http+docker://localunixsocket'

if you get different values for base_url, (ie, involving 192.168.59.103) that'll help narrow it down.

Also, can you report the output of env | grep DOCKER and docker version?

from universe-starter-agent.

gpunti avatar gpunti commented on September 7, 2024

I get the same results as you:

Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import universe.remotes.docker_remote
>>> client,info = universe.remotes.docker_remote.get_client()
>>> client.base_url
'http+docker://localunixsocket'
>>> import docker
>>> client2 = docker.Client()
>>> client2.base_url
'http+docker://localunixsocket'

'env | grep DOCKER' outputs nothing.

docker --version
Docker version 1.13.0, build 49bf474

python --version
Python 3.5.2 :: Anaconda custom (x86_64)

from universe-starter-agent.

tlbtlbtlb avatar tlbtlbtlb commented on September 7, 2024

Mysterious. I can reproduce the error when I set DOCKER_HOST to something nonexistent, for example:

$ env DOCKER_HOST=tcp://127.99.99.99:9999 python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdb
>>> from universe import runtimes, remotes
>>> runtime = runtimes.registration.runtime_spec('flashgames')
>>> m = remotes.docker_remote.DockerManager(runtime, 1)
Traceback (most recent call last):
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 91, in create_connection
    raise err
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 81, in create_connection
    sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
    chunked=chunked)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 362, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/Users/tlb/anaconda3/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/Users/tlb/anaconda3/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/Users/tlb/anaconda3/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/Users/tlb/anaconda3/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/Users/tlb/anaconda3/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 167, in connect
    conn = self._new_conn()
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 147, in _new_conn
    (self.host, self.timeout))
requests.packages.urllib3.exceptions.ConnectTimeoutError: (<requests.packages.urllib3.connection.HTTPConnection object at 0x107cbd9e8>, 'Connection to 127.99.99.99 timed out. (connect timeout=60)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 403, in send
    timeout=timeout
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 623, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 281, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.99.99.99', port=9999): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x107cbd9e8>, 'Connection to 127.99.99.99 timed out. (connect timeout=60)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/client.py", line 116, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/api/daemon.py", line 76, in version
    return self._result(self._get(url), json=True)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/utils/decorators.py", line 47, in inner
    return f(self, *args, **kwargs)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/client.py", line 139, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 459, in send
    raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='127.99.99.99', port=9999): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x107cbd9e8>, 'Connection to 127.99.99.99 timed out. (connect timeout=60)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tlb/openai/universe/universe/remotes/docker_remote.py", line 44, in __init__
    self._assigner = PortAssigner(reuse=reuse)
  File "/Users/tlb/openai/universe/universe/remotes/docker_remote.py", line 162, in __init__
    self.client, self.info = get_client()
  File "/Users/tlb/openai/universe/universe/remotes/docker_remote.py", line 156, in get_client
    return docker.Client(base_url=host, version=client_api_version), info
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/client.py", line 99, in __init__
    self._version = self._retrieve_server_version()
  File "/Users/tlb/anaconda3/lib/python3.5/site-packages/docker/client.py", line 124, in _retrieve_server_version
    'Error while fetching server API version: {0}'.format(e)
docker.errors.DockerException: Error while fetching server API version: HTTPConnectionPool(host='127.99.99.99', port=9999): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x107cbd9e8>, 'Connection to 127.99.99.99 timed out. (connect timeout=60)'))
>>> pdb.pm()
> /Users/tlb/anaconda3/lib/python3.5/site-packages/docker/client.py(124)_retrieve_server_version()
-> 'Error while fetching server API version: {0}'.format(e)
(Pdb) p self.base_url
'http://127.99.99.99:9999'

Can you try the same experiment and see if base_url is getting set somewhere else?

from universe-starter-agent.

gpunti avatar gpunti commented on September 7, 2024

Yes, I get the same error as yours.
docker.errors.DockerException: Error while fetching server API version: HTTPConnectionPool(host='127.99.99.99', port=9999): Max retries exceeded with url: /version (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x10cb1b5f8>, 'Connection to 127.99.99.99 timed out. (connect timeout=60)'))

So in my case it always uses DOCKER_HOST. And if it's not defined ( as it is my case ) it's uses the default 192.168.59.103. Do you always have DOCKER_HOST variable setup beforehand ?

from universe-starter-agent.

tlbtlbtlb avatar tlbtlbtlb commented on September 7, 2024

I never set DOCKER_HOST unless I'm using a remote server. It should use http+docker://localunixsocket if DOCKER_HOST isn't set, which should cause it to use a local unix socket.

Possibly, setting $ export DOCKER_HOST=http+unix://var/run/docker.sock will make it work.

This issue: docker/docker-py#406 mentions looking up the boot2docker hostname. Do you have an entry for boot2docker in /etc/hosts?

You might try asking at https://github.com/docker/docker-py/issues, with a simple reproduction looking like

>>> import docker
>>> client = docker.Client()
>>> client.base_url
'http+docker://localunixsocket'
>>> client.ping()
'OK'

(except you'll presumably get an error instead of 'OK').

from universe-starter-agent.

gpunti avatar gpunti commented on September 7, 2024

Ok finally found the issue. There are ~/.bashrc and ~/.bash_profile. When running the Terminal app in Mac only .bash_profile is executed, in which no DOCKER_HOST was set. But when spawning shells the .bashrc was executed which did define DOCKER_HOST to an invalid address.

This only happens in Mac. On Linux all terminals you run are considered as non-login shells.

So checking 'set | grep DOCKER' was useless because it doesn't really tell you what you configuration is going to be in a spawned (non-login) shell.

Thanks for you support!

http://unix.stackexchange.com/questions/119627/why-are-interactive-shells-on-osx-login-shells-by-default

from universe-starter-agent.

tlbtlbtlb avatar tlbtlbtlb commented on September 7, 2024

Ah, of course, it happens when universe-start-eragent creates the tmux sessions which are a non-login shell (unlike Terminal shells). Thanks for the resolution.

from universe-starter-agent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.