2016-05-23 10 views
0

Ich habe kürzlich einen EndpointConnectionError (nach einem langen Timeout) erhalten, als ich versuchte, DynamoDB aus einem Docker-Container auf dem Mac zu kontaktieren. Derselbe Code und das gleiche Setup haben vorher gut funktioniert.botocore.exceptions.EndpointConnectionError aus dem Mac-Docker-Container

Hier ist ein Beispielcode:

>>> from boto3 import resource 
>>> r = resource('dynamodb') 
>>> table = r.Table('Users') 
>>> table.put_item(Item={'id':'987987'}) 

My ~/.aws/config:

[default] 
output = json 
region = us-east-1 

-Code Ich verwende den Behälter (unter Mac OS) wieder aufbauen und neu starten:

#!/bin/sh 
docker-machine ssh default "docker ps | awk 'NR > 1 {print \$1}' | xargs --no-run-if-empty docker kill" 
docker build -t <image_name> . 
docker-machine ssh default "docker run -p 80:80 -v /var/datenight_secret:/var/www/.aws <image_name>" & 

Stacktrace:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/usr/local/lib/python3.4/dist-packages/boto3/resources/factory.py", line 518, in do_action 
    response = action(self, *args, **kwargs) 
    File "/usr/local/lib/python3.4/dist-packages/boto3/resources/action.py", line 83, in __call__ 
    response = getattr(parent.meta.client, operation_name)(**params) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/client.py", line 258, in _api_call 
    return self._make_api_call(operation_name, kwargs) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/client.py", line 537, in _make_api_call 
    operation_model, request_dict) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 117, in make_request 
    return self._send_request(request_dict, operation_model) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 146, in _send_request 
    success_response, exception): 
    File "/usr/local/lib/python3.4/dist-packages/botocore/endpoint.py", line 219, in _needs_retry 
    caught_exception=caught_exception) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/hooks.py", line 227, in emit 
    return self._emit(event_name, kwargs) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/hooks.py", line 210, in _emit 
    response = handler(**kwargs) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 183, in __call__ 
    if self._checker(attempts, response, caught_exception): 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 251, in __call__ 
    caught_exception) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 274, in _should_retry 
    return self._checker(attempt_number, response, caught_exception) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 314, in __call__ 
    caught_exception) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 223, in __call__ 
    attempt_number, caught_exception) 
    File "/usr/local/lib/python3.4/dist-packages/botocore/retryhandler.py", line 356, in _check_caught_exception 
    raise caught_exception 
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://dynamodb.us-east-1.amazonaws.com/" 

Ich bekomme das gleiche Verhalten (hängt für eine lange Zeit, dann stacktrace), wenn ich uns-Ost-2 oder Eu-West-1. Die gleichen Konfigurations- und Berechtigungsdateien funktionieren auf einem us-east-1 EC2-Host oder auf meinem Mac OS.

Basierend auf this question habe ich sichergestellt, dass HTTP_PROXY und HTTPS_PROXY beide leer sind.

Python-Version ist Python 3.4.3.

+0

Können Sie über den Container auf das Internet zugreifen? 'ping www.google.com' – helloV

Antwort

1

ausgeführt docker-machine stop default; docker-machine start default das Problem behoben. Wie zutiefst unbefriedigend - ich dachte, das würde ein interessantes Problem sein, das mir etwas über das Networking beibringen würde.