Aws-sam-cli: `sam build --use-container` fails with hello_world, ConnectionError, FileNotFoundError

Created on 25 Jan 2019  路  8Comments  路  Source: aws/aws-sam-cli

Description

On MacOSX Mojave (10.14.2) sam build --use-container fails with the "hello-world" app in the aws lambda quick start guide.

Steps to reproduce

Install both awscli and aws-sam-cli with homebrew. Follow the guide.

Observed result

Error message:

2019-01-24 20:01:34 Building resource 'HelloWorldFunction'
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/transport/unixconn.py", line 42, in connect
    sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/transport/unixconn.py", line 42, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.10.0', 'console_scripts', 'sam')()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/build/command.py", line 94, in cli
    skip_pull_image, parameter_overrides)  # pragma: no cover
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/commands/build/command.py", line 132, in do_cli
    artifacts = builder.build()
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 129, in build
    lambda_function.runtime)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 201, in _build_function
    runtime)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 249, in _build_function_on_container
    self._container_manager.run(container)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/local/docker/manager.py", line 75, in run
    is_image_local = self.has_image(image_name)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/samcli/local/docker/manager.py", line 153, in has_image
    self.docker_client.images.get(image_name)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/models/images.py", line 316, in get
    return self.prepare_model(self.client.api.inspect_image(name))
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/api/image.py", line 245, in inspect_image
    self._get(self._url("/images/{0}/json", image)), True
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/docker/api/client.py", line 225, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/Cellar/aws-sam-cli/0.10.0/libexec/lib/python3.7/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

Interventions tried

  • aws --version shows:
    aws-cli/1.16.94 Python/3.7.2 Darwin/18.2.0 botocore/1.12.84
  • reinstalled awscli and aws-sam-cli
  • brew doctor reports no error

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: MacOSX Mojave (10.14.2)
  2. sam --version:
    > SAM CLI, version 0.10.0

Add --debug flag to command you are running

Most helpful comment

I also faced the same issue.
In my case, I simply forgot to run a Docker service. After starting a Docker service on my machine, it resolved.

You didn't forget, docs just don't tell us to make it.

All 8 comments

I am also facing this issue

I also faced the same issue.
In my case, I simply forgot to run a Docker service. After starting a Docker service on my machine, it resolved.

It's been a few days since I last posted this issue. In my case, I eventually moved away from AWS lambda to Google Cloud Functions. The documentation of GCF is easy to follow step by step; hello-world type of apps didn't fail; local emulator to test/debug GCF locally before deployment was also easy to use; and later I got my actual app working.

I also faced the same issue.
In my case, I simply forgot to run a Docker service. After starting a Docker service on my machine, it resolved.

You didn't forget, docs just don't tell us to make it.

same here; just fire up docker and "problem" solved.
docs should be updated in order to advice this dependency

cheers!

The Quickstarts do link out to our installation docs which call out docker needs to be installed. What would make this clearer?

totally true @jfuss, I missed that link.
thanks

Closing this issue, as installations docs point to docker needing to be installed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drumadrian picture drumadrian  路  3Comments

asyba picture asyba  路  3Comments

cmccoypdx picture cmccoypdx  路  3Comments

goldenbearkin picture goldenbearkin  路  3Comments

GerbenRampaart picture GerbenRampaart  路  3Comments