Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid volume specification #461

Closed
uvaisTrivecta opened this issue Jun 6, 2018 · 40 comments
Closed

invalid volume specification #461

uvaisTrivecta opened this issue Jun 6, 2018 · 40 comments
Labels

Comments

@uvaisTrivecta
Copy link

uvaisTrivecta commented Jun 6, 2018

Im facing the invalid volume specification error when trying to run the sample HelloWorld using sam local . I am running Docker Toolbox on Windows8.1 Pro. Sam Version 0.3.0. Docker version 18.03.0-ce, build 0520e24302

Output : (with out --docker-volume-basedir)

C:\Python27\Lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-java{{cookiecutter.project_name}}>sam local start-api
2018-06-06 16:11:24 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2018-06-06 16:11:24 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template

2018-06-06 16:11:24 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-06-06 16:11:30 Invoking helloworld.App::handleRequest (java8)
2018-06-06 16:11:30 Found credentials in shared credentials file: ~/.aws/credentials
2018-06-06 16:11:30 Decompressing C:\Python27\Lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-java{{cookiecutter.project_name}}\target\HelloWorld-1.0.jar

Fetching lambci/lambda:java8 Docker container image......
2018-06-06 16:11:34 Mounting c:\users\lenovo2\appdata\local\temp\tmp2vg4ry as /var/task:ro inside runtime container
[2018-06-06 16:11:34,845] ERROR in app: Exception on /hello [GET]
Traceback (most recent call last):
File "c:\python27\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\python27\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\python27\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "c:\python27\lib\site-packages\samcli\local\apigw\service.py", line 161, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream, stderr=self.stderr)
File "c:\python27\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 80, in invoke
stdout=stdout, stderr=stderr)
File "c:\python27\lib\site-packages\samcli\local\lambdafn\runtime.py", line 83, in invoke
self._container_manager.run(container)
File "c:\python27\lib\site-packages\samcli\local\docker\manager.py", line 61, in run
container.create()
File "c:\python27\lib\site-packages\samcli\local\docker\container.py", line 110, in create
real_container = self.docker_client.containers.create(self._image, **kwargs)
File "c:\python27\lib\site-packages\docker\models\containers.py", line 824, in create
resp = self.client.api.create_container(**create_kwargs)
File "c:\python27\lib\site-packages\docker\api\container.py", line 410, in create_container
return self.create_container_from_config(config, name)
File "c:\python27\lib\site-packages\docker\api\container.py", line 421, in create_container_from_config
return self._result(res, True)
File "c:\python27\lib\site-packages\docker\api\client.py", line 231, in _result
self._raise_for_status(response)
File "c:\python27\lib\site-packages\docker\api\client.py", line 227, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "c:\python27\lib\site-packages\docker\errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("invalid volume specification: 'c:\users\lenovo2\appdata\local\temp\tmp2vg4ry:/var/task:ro'")
2018-06-06 16:11:34 127.0.0.1 - - [06/Jun/2018 16:11:34] "GET /hello HTTP/1.1" 502 -
2018-06-06 16:11:35 127.0.0.1 - - [06/Jun/2018 16:11:35] "GET /favicon.ico HTTP/1.1" 403 -

Output : (with --docker-volume-basedir)
C:\Python27\Lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-java{{cookiecutter.project_name}}>sam local start-api --docker-volume-basedir \c\Users
2018-06-06 16:15:10 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2018-06-06 16:15:10 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-06-06 16:15:10 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-06-06 16:15:14 Invoking helloworld.App::handleRequest (java8)
2018-06-06 16:15:14 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:java8 Docker container image......
2018-06-06 16:15:17 Mounting C:\c\Users\target\HelloWorld-1.0.jar as /var/task:ro inside runtime container
[2018-06-06 16:15:18,585] ERROR in app: Exception on /hello [GET]
Traceback (most recent call last):
File "c:\python27\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\python27\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\python27\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "c:\python27\lib\site-packages\samcli\local\apigw\service.py", line 161, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream, stderr=self.stderr)
File "c:\python27\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 80, in invoke
stdout=stdout, stderr=stderr)
File "c:\python27\lib\site-packages\samcli\local\lambdafn\runtime.py", line 83, in invoke
self._container_manager.run(container)
File "c:\python27\lib\site-packages\samcli\local\docker\manager.py", line 61, in run
container.create()
File "c:\python27\lib\site-packages\samcli\local\docker\container.py", line 110, in create
real_container = self.docker_client.containers.create(self._image, **kwargs)
File "c:\python27\lib\site-packages\docker\models\containers.py", line 824, in create
resp = self.client.api.create_container(**create_kwargs)
File "c:\python27\lib\site-packages\docker\api\container.py", line 410, in create_container
return self.create_container_from_config(config, name)
File "c:\python27\lib\site-packages\docker\api\container.py", line 421, in create_container_from_config
return self._result(res, True)
File "c:\python27\lib\site-packages\docker\api\client.py", line 231, in _result
self._raise_for_status(response)
File "c:\python27\lib\site-packages\docker\api\client.py", line 227, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "c:\python27\lib\site-packages\docker\errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("invalid volume specification: 'C:\c\Users\target\HelloWorld-1.0.jar:/var/task:ro'")
2018-06-06 16:15:18 127.0.0.1 - - [06/Jun/2018 16:15:18] "GET /hello HTTP/1.1" 502 -
2018-06-06 16:15:18 127.0.0.1 - - [06/Jun/2018 16:15:18] "GET /favicon.ico HTTP/1.1" 403 -

@drissamri
Copy link

I'm experiencing the same when trying to run aws-sam-cli in my docker image:

docker run -it --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$(PWD)":/var/opt \ -p "3000:3000" \ drissamri/aws-sam-cli local start-api --docker-volume-basedir "${PWD}" --host 0.0.0.0

Fetching lambci/lambda:java8 Docker container image...... 2018-06-10 13:54:04 Mounting /Users/drissamri/workspace/drissamri/aws-serverless-starter/spring-cloud-functions/target/spring-example-1.0.0-aws.jar as /var/task:ro inside runtime container [2018-06-10 13:54:04,932] ERROR in app: Exception on /report [POST] Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "/usr/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/lib/python2.7/site-packages/samcli/local/apigw/service.py", line 161, in _request_handler self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream, stderr=self.stderr) File "/usr/lib/python2.7/site-packages/samcli/commands/local/lib/local_lambda.py", line 80, in invoke stdout=stdout, stderr=stderr) File "/usr/lib/python2.7/site-packages/samcli/local/lambdafn/runtime.py", line 83, in invoke self._container_manager.run(container) File "/usr/lib/python2.7/site-packages/samcli/local/docker/manager.py", line 63, in run container.start(input_data=input_data) File "/usr/lib/python2.7/site-packages/samcli/local/docker/container.py", line 167, in start real_container.start() File "/usr/lib/python2.7/site-packages/docker/models/containers.py", line 374, in start return self.client.api.start(self.id, **kwargs) File "/usr/lib/python2.7/site-packages/docker/utils/decorators.py", line 19, in wrapped return f(self, resource_id, *args, **kwargs) File "/usr/lib/python2.7/site-packages/docker/api/container.py", line 1063, in start self._raise_for_status(res) File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 227, in _raise_for_status raise create_api_error_from_http_exception(e) File "/usr/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception raise cls(e, response=response, explanation=explanation) APIError: 400 Client Error: Bad Request ("OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/drissamri/workspace/drissamri/aws-serverless-starter/spring-cloud-functions/target/spring-example-1.0.0-aws.jar\\\" to rootfs \\\"/var/lib/docker/overlay2/c73f1af49221fdefbcce8c1739338aef1ee6d3af1afb33080c07df7930340855/merged\\\" at \\\"/var/lib/docker/overlay2/c73f1af49221fdefbcce8c1739338aef1ee6d3af1afb33080c07df7930340855/merged/var/task\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type") 2018-06-10 13:54:04 172.17.0.1 - - [10/Jun/2018 13:54:04] "POST /report HTTP/1.1" 502 -

@jsantoru
Copy link

i'm seeing the same issue as @uvaisTrivecta

@DanielLaberge
Copy link

Same issue here with the following installed on Windows 10 Pro Version 1803 Build 17134.112.

I used the sample project created by sam init.

I've also tried getting it to work with the new Docker for Windows, but without documentation I haven't figured how to get it talking to docker-machine.

Any help/workaround would be much appreciated.

C:\Users\Daniel\Documents\Repos\TestProject\sam-app>sam local start-api
2018-06-19 10:22:11 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2018-06-19 10:22:11 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-06-19 10:22:12  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-06-19 10:22:13 Invoking app.lambda_handler (nodejs8.10)
[... Full stack trace below ...]
docker.errors.APIError: 500 Server Error: Internal Server Error ("invalid volume specification: 'C:\Users\Daniel\Documents\Repos\TestProject\sam-app\hello_world:/var/task:ro'")

$ docker --version
Docker version 18.03.0-ce, build 0520e24302

$ docker-machine --version
docker-machine.exe version 0.14.0, build 89b8332

$ python --version
Python 3.6.5

$ pip freeze
arrow==0.12.1
aws-sam-cli==0.4.0
aws-sam-translator==1.6.0
binaryornot==0.4.4
boto3==1.7.40
botocore==1.10.40
certifi==2018.4.16
chardet==3.0.4
click==6.7
cookiecutter==1.6.0
docker==3.4.0
docker-pycreds==0.3.0
docutils==0.14
enum34==1.1.6
Flask==1.0.2
future==0.16.0
idna==2.7
itsdangerous==0.24
Jinja2==2.10
jinja2-time==0.2.0
jmespath==0.9.3
jsonschema==2.6.0
MarkupSafe==1.0
poyo==0.4.1
pypiwin32==220
python-dateutil==2.7.3
PyYAML==3.12
requests==2.19.1
s3transfer==0.1.13
six==1.11.0
urllib3==1.23
websocket-client==0.48.0
Werkzeug==0.14.1
whichcraft==0.4.1

Stack trace:

C:\Users\Daniel\Documents\Repos\TestProject\sam-app>sam local start-api
2018-06-19 10:22:11 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2018-06-19 10:22:11 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-06-19 10:22:12  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-06-19 10:22:13 Invoking app.lambda_handler (nodejs8.10)
2018-06-19 10:22:13 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:nodejs8.10 Docker container image......
2018-06-19 10:22:14 Mounting C:\Users\Daniel\Documents\Repos\TestProject\sam-app\hello_world as /var/task:ro inside runtime container
2018-06-19 10:22:14 Exception on /hello [GET]
Traceback (most recent call last):
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\api\client.py", line 229, in _raise_for_status
    response.raise_for_status()
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\requests\models.py", line 939, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://192.168.99.100:2376/v1.35/containers/create

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\_compat.py", line 35, in reraise
    raise value
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\samcli\local\apigw\service.py", line 185, in _request_handler
    self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream, stderr=self.stderr)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\samcli\commands\local\lib\local_lambda.py", line 80, in invoke
    stdout=stdout, stderr=stderr)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\samcli\local\lambdafn\runtime.py", line 83, in invoke
    self._container_manager.run(container)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\samcli\local\docker\manager.py", line 61, in run
    container.create()
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\samcli\local\docker\container.py", line 110, in create
    real_container = self.docker_client.containers.create(self._image, **kwargs)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\models\containers.py", line 824, in create
    resp = self.client.api.create_container(**create_kwargs)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\api\container.py", line 410, in create_container
    return self.create_container_from_config(config, name)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\api\container.py", line 421, in create_container_from_config
    return self._result(res, True)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\api\client.py", line 235, in _result
    self._raise_for_status(response)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\api\client.py", line 231, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "C:\Users\Daniel\AppData\Roaming\Python\Python36\site-packages\docker\errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("invalid volume specification: 'C:\Users\Daniel\Documents\Repos\TestProject\sam-app\hello_world:/var/task:ro'")

@jfuss
Copy link
Contributor

jfuss commented Jun 20, 2018

@DanielLaberge and I were able to get his install working. Here are some steps that should hopefully help get over this problem.

  1. Uninstall docker toolkit (this is deprecated)
  2. Delete any outstanding docker files (config files, etc)
  3. Install Docker for windows
  4. Do all the enable Hyper-V stuff for docker
  5. Reboot
  6. Make sure docker is running and run docker run hello-world. This step is to make sure docker is running and can download images correctly.
  7. Run your sam commands.

I believe this is a docker installation problem and not with the cli (given what @DanielLaberge and I did). I am going to leave this open for a little while though.

@DanielLaberge
Copy link

DanielLaberge commented Jun 20, 2018

Just to clarify: I deleted the following items left behind by docker-toolbox:

  • The config files in %USERPROFILE%\.docker
  • The 4 or 5 docker environment variables (most of them have docker in their name)

Thanks again @jfuss.

@uvaisTrivecta
Copy link
Author

uvaisTrivecta commented Jun 21, 2018

@jfuss @DanielLaberge Docker for windows is available only for Windows 10 Pro, the issue which i face is with Windows8.1 Pro. So u mean that aws-sam-cli can only be worked with Windows10 since docker for windows is available for the same? If not kindly help us with some solutions ...

@jsantoru
Copy link

@jfuss thanks for your help in investigating this. so just to be explicit, is the following correct?

  • aws-sam-cli requires docker for windows which requires windows 10 Pro
  • windows 7 or 8:
    • cannot use aws-sam-cli for running locally
    • must use aws-sam-local (v0.2.11) with docker toolbox if you want to run locally
  • windows 10 Pro:
    • can use aws-sam-cli with docker for windows

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@uvaisTrivecta and @jsantoru Where does it state we don't support anything but Windows 10? If this is in response to my comment above, those are the sets we tool to get it working for @DanielLaberge. If able, I encourage everyone to update to Docker for windows.

@uvaisTrivecta and @jsantoru Are you guys able to run docker run hello-world?

@jsantoru
Copy link

@jfuss according to the docker site: https://store.docker.com/editions/community/docker-ce-desktop-windows

Get Docker Community Edition for Windows
Docker for Windows is available for free.
Requires Microsoft Windows 10 Professional or Enterprise 64-bit. For previous versions get Docker Toolbox.

so if the solution is to use docker for windows and not use docker toolbox, then it looks like we'll need windows 10.

i might be missing something, but that's my understanding to this point

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@jsantoru As your comment says: "For previous versions get Docker Toolbox."

@jsantoru
Copy link

@jfuss this first line still applies though doesn't it?

Requires Microsoft Windows 10 Professional or Enterprise 64-bit.

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@uvaisTrivecta From your error message above I see: Decompressing C:\Python27\Lib\site-packages\samcli\local\init\templates\cookiecutter-aws-sam-hello-java{{cookiecutter.project_name}}\target\HelloWorld-1.0.jar

Why are you mounting the non-generated cookiecutter project? Don't do this! This is for generating the sam app from sam init.

We had some issue with .jars not mounting correctly. This could be the same thing. Could you try and update to v0.4.0? My hunch is it is a mix of both issues.

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@jsantoru You are looking way to deep into this. What that means is if you are using Windows 10 Professional or Enterprise 64-bit, use docker for windows. If that does not apply to you use docker toolkit.

Put very clearly: Yes we support docker toolkit but use docker for windows if you can.

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@drissamri It looks like you were also using a jar. Can you upgrade to v0.4.0 and see if you get the same mount issue. We fixed an issue related to .jar that I think it causing this issue.

@jsantoru For the functions that cause the 'invalid volume specification`, what does your CodeUri look like? Is it a zip or jar?

@jsantoru
Copy link

@jfuss it's a jar, so I'll upgrade to v0.4.0 and see if that resolves it.

thanks again for helping out with this, much appreciated.

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@jsantoru Please let me know if that ended up working for you.

@uvaisTrivecta
Copy link
Author

@jfuss Many Thanks for looking in to this.

  1. Im able to run docker run hello-world
  2. I tried with upgrading version 0.4.0, but still the same issue exists 👎 👎

@jfuss
Copy link
Contributor

jfuss commented Jun 21, 2018

@uvaisTrivecta What does your CodeUri in your template look like? Did you generate your own project or still using \samcli\local\init\templates\cookiecutter-aws-sam-hello-java{{cookiecutter.project_name}}\target\HelloWorld-1.0.jar?

@uvaisTrivecta
Copy link
Author

uvaisTrivecta commented Jun 21, 2018

@jfuss tried with my own project only and also cookiecutter.project_name.
getting the same error as invalid volume specification .

Error log : (Sharing the log again) sam-cli version 0.4.0

E:\Aws Lambda\aws-serverless-java-container\samples\spring\pet-store>sam local start-api --template sam.yaml
2018-06-22 12:21:52 Mounting PetStoreFunction at http://127.0.0.1:3000/{proxy+} [GET, DELETE, PUT, POST, HEAD, OPTIONS, PATCH]
2018-06-22 12:21:52 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-06-22 12:21:52 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-06-22 12:21:58 Invoking com.amazonaws.serverless.sample.spring.StreamLambdaHandler::handleRequest (java8)
2018-06-22 12:21:58 Found credentials in shared credentials file: ~/.aws/credentials
2018-06-22 12:21:58 Decompressing E:\Aws Lambda\aws-serverless-java-container\samples\spring\pet-store\target\serverless-spring-example-1.0-SNAPSHOT.jar

Fetching lambci/lambda:java8 Docker container image......
2018-06-22 12:22:36 Mounting c:\users\lenovo2\appdata\local\temp\tmpotnj1v as /var/task:ro inside runtime container
2018-06-22 12:22:47 Exception on /pets/1 [GET]
Traceback (most recent call last):
File "c:\python27\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\python27\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\python27\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "c:\python27\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "c:\python27\lib\site-packages\samcli\local\apigw\service.py", line 185, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream, stderr=self.stderr)
File "c:\python27\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 80, in invoke
stdout=stdout, stderr=stderr)
File "c:\python27\lib\site-packages\samcli\local\lambdafn\runtime.py", line 83, in invoke
self._container_manager.run(container)
File "c:\python27\lib\site-packages\samcli\local\docker\manager.py", line 61, in run
container.create()
File "c:\python27\lib\site-packages\samcli\local\docker\container.py", line 110, in create
real_container = self.docker_client.containers.create(self._image, **kwargs)
File "c:\python27\lib\site-packages\docker\models\containers.py", line 824, in create
resp = self.client.api.create_container(**create_kwargs)
File "c:\python27\lib\site-packages\docker\api\container.py", line 410, in create_container
return self.create_container_from_config(config, name)
File "c:\python27\lib\site-packages\docker\api\container.py", line 421, in create_container_from_config
return self._result(res, True)
File "c:\python27\lib\site-packages\docker\api\client.py", line 235, in _result
self._raise_for_status(response)
File "c:\python27\lib\site-packages\docker\api\client.py", line 231, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "c:\python27\lib\site-packages\docker\errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("invalid volume specification: 'c:\users\lenovo2\appdata\local\temp\tmpotnj1v:/var/task:ro'")

@drissamri
Copy link

@jfuss I've upgraded to 0.4.0 but it's still not working. I'm running on OSX and locally it works perfectly on 0.3.0 and 0.4.0, but when I try to run it inside a docker image (for easier automated testing with sam local) it keeps on failing.

@bryanburke
Copy link

bryanburke commented Jul 3, 2018

This issue is particular to setups using Docker Toolbox on Windows, which is the only option for people running a version of Windows < 10 Pro. It appears to be caused by LocalLambdaRunner._get_code_path() in two places:

  1. https://github.com/awslabs/aws-sam-cli/blob/dd3c556ad70cc4d015f72e72a6487da9619589a6/samcli/commands/local/lib/local_lambda.py#L172
  2. https://github.com/awslabs/aws-sam-cli/blob/dd3c556ad70cc4d015f72e72a6487da9619589a6/samcli/commands/local/lib/local_lambda.py#L178

The calls to os.path.abspath(), os.path.normpath(), and os.path.join() happen in the context of the Windows host OS and therefore attempt to produce valid Windows-style paths. This ultimately causes aws-sam-cli to convert the value of the --docker-volume-basedir argument to a Windows-style path before passing it as part of the volume specification to docker run, which in turn passes the path onto Boot2Docker.

As an example, LocalLambdaRunner._get_code_path() is converting the Unix-style path /c/Users/johndoe/sam-app (as given to --docker-volume-basedir) to the Windows-style path C:\c\Users\johndoe\sam-app.

Note that this path conversion happens within aws-sam-cli's code and therefore cannot be blamed on Docker misconfiguration or choice of shell. You can confirm this by adding print() statements before and after the lines I referenced above. Of course, this issue is confounded by Docker misconfigurations and shell-specific behaviors (in particular, MSYS2's automatic path conversion).

This issue effectively makes aws-sam-cli unusable on versions of Windows < 10 Pro.

@jfuss
Copy link
Contributor

jfuss commented Jul 5, 2018

@bryanburke Thanks for the detailed response. I didn't have data to suggest it wasn't a docker issue before and didn't understand the differences between Docker Toolbox and Docker for Windows (hence the I believe in my pervious statement and why I left this issue open).

Do you by chance know, if unix-style paths are accepted in Docker For Windows? Not a big deal if you don't, this is a pretty easy thing we can validate.

Updating labels.

@bryanburke
Copy link

bryanburke commented Jul 6, 2018

@jfuss Thank you for labeling this issue as critical.

Regarding paths Docker for Windows can accept, according to the Docker documentation:

On Windows, the paths must be specified using Windows-style semantics.

I was thinking about possible solutions to this issue. One approach might be the following:

  1. Call docker.client.DockerClient.info() to determine the OS on which the Docker daemon is running. This OS is the container host and may be:
    • The same host OS running Python, as when using Docker for Windows.
    • Boot2Docker, as when using Docker Toolbox.
    • The host OS of a remote Docker container host (Linux, for example).
  2. Check os.name to determine the Python host OS.
  3. If the Python host OS is Windows but the container host OS is not Windows:
    1. Check if the user passed a value to --docker-volume-basedir.
    2. If yes, then convert (if necessary) that value to a Unix-style path.
    3. If no, then convert cwd to a Unix-style path.
  4. Construct codeuri using path semantics appropriate for the container host platform.

The above approach might also accommodate setups in which Docker for Windows/Docker Toolbox is acting as a client to a remote non-Windows Docker container host.

By default, Docker Toolbox creates a VirtualBox share mapping C:\Users in Windows to /c/Users in Boot2Docker. This means that, out of the box, passing a path like /c/Users/johndoe/sam-app to docker run should form a valid volume specification.

@bryanburke
Copy link

I can confirm that this issue also affects setups in which DOCKER_HOST points to a remote non-Windows container host, regardless of what version of Docker is acting as the client (Docker Toolbox, Docker for Windows, standalone Docker CLI, etc.).

As a (very hacky) temporary workaround for version 0.4.0 of aws-sam-cli, you can do the following:

  1. In your Python site-packages directory, find samcli\commands\local\lib\local_lambda.py and make the following changes:
    1. Comment out line 172: # self.cwd = os.path.abspath(self.cwd)
    2. Comment out line 178: # codeuri = os.path.normpath(os.path.join(self.cwd, codeuri))
    3. Below line 178, add this statement: codeuri = "/".join([self.cwd, codeuri])
    4. Lines 171-179 of local_lambda.py should now look like this:
        # Make sure cwd is an absolute path
        # self.cwd = os.path.abspath(self.cwd)

        # Next, let us get absolute path of function code.
        # Codepath is always relative to current working directory
        # If the path is relative, then construct the absolute version
        if not os.path.isabs(codeuri):
            # codeuri = os.path.normpath(os.path.join(self.cwd, codeuri))
            codeuri = "/".join([self.cwd, codeuri])
  1. When calling sam local, give the absolute Unix-style path to your project directory via --docker-volume-basedir. Examples:
    • For Command Prompt: sam local start-api --docker-volume-basedir /c/Users/johndoe/sam-app
    • For MSYS2 (e.g., Git Bash): MSYS2_ARG_CONV_EXCL="*" sam local start-api --docker-volume-basedir /c/Users/johndoe/sam-app

Explanation:

  • The code changes ensure that Python in Windows does not call any os.path functions when constructing codeuri.
  • As a result, the code does no path checking or normalization, meaning that you MUST specify --docker-volume-basedir with an absolute Unix-style path.
  • Setting MSYS2_ARG_CONV_EXCL="*" disables MSYS2's path mangling for the remainder of the command. See here for more details about this environment variable.

@uvaisTrivecta
Copy link
Author

@bryanburke I made the changes as per your command, now I landed in a different issue,
could you please help me on the same ?
Kindly find the below log, after changing the file local_lambda.py
Lenovo2@New MINGW64 /e/Aws Lambda/aws-serverless-java-container/samples/spring/pet-store (master)
$ MSYS2_ARG_CONV_EXCL="*" sam local start-api --template sam.yaml --docker-volume-basedir /e/Aws\ Lambda/aws-serverless-java-container/samples/spring/pet-store

2018-07-09 18:01:17 Mounting PetStoreFunction at http://127.0.0.1:3000/{proxy+} [GET, DELETE, PUT, POST, HEAD, OPTIONS, PATCH]
2018-07-09 18:01:17 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-07-09 18:01:17 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-07-09 18:01:30 Invoking com.amazonaws.serverless.sample.spring.StreamLambdaHandler::handleRequest (java8)
2018-07-09 18:01:30 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:java8 Docker container image......
2018-07-09 18:01:34 Mounting /e/Aws Lambda/aws-serverless-java-container/samples/spring/pet-store/target/serverless-spring-example-1.0-SNAPSHOT.jar as /var/task:ro inside runtime container
←[32mSTART RequestId: 712ddfca-f4ca-4e3c-8123-c7fe44453d64 Version: $LATEST←[0m
←[31mjava.lang.ClassNotFoundException: com.amazonaws.serverless.sample.spring.StreamLambdaHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
←[0m
←[32mEND RequestId: 712ddfca-f4ca-4e3c-8123-c7fe44453d64←[0m
←[32mREPORT RequestId: 712ddfca-f4ca-4e3c-8123-c7fe44453d64 Duration: 17.18 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 3 MB ←[0m
2018-07-09 18:01:38 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received:

@bryanburke
Copy link

bryanburke commented Jul 10, 2018

@jfuss It looks like the issue @uvaisTrivecta is having likely stems from LambdaRuntime._get_code_dir() here: https://github.com/awslabs/aws-sam-cli/blob/dd3c556ad70cc4d015f72e72a6487da9619589a6/samcli/local/lambdafn/runtime.py#L170

LambdaRuntime decompresses a jar/zip archive into a platform-specific temp directory and then passes the path to that temp directory onto LambdaContainer. When this mixture of Windows Python host and non-Windows container host occurs, I think LambdaRuntime would need to convert the generated temp directory path to its Unix-style equivalent (e.g., C:\Users\johndoe\AppData\Local\Temp\temp123 => '/c/Users/johndoe/AppData/Local/Temp/temp123`).

Here is my (probably incomplete) guess as to how a possible solution might look:

  1. Call docker.client.DockerClient.info() to determine the OS on which the Docker daemon is running. This OS is the container host and may be:
    • The same host OS running Python, as when using Docker for Windows.
    • Boot2Docker, as when using Docker Toolbox.
    • The host OS of a remote Docker container host (Linux, for example).
  2. Check os.name to determine the Python host OS.
  3. If the Python host OS is Windows but the container host OS is not Windows:
    1. Construct codeuri as an absolute Windows-style path.
    2. If codeuri points to a jar/zip archive:
      1. Decompress the archive into a temp directory.
      2. Convert the temp directory path to a Unix-style path.
    3. Else if codeuri points to a directory, convert it to a Unix-style path as-is.

I think this logic might allow --docker-volume-basedir to accept Windows-style paths, regardless of setup. Additionally, it might be possible to use pathlib.PurePosixPath to help solve the path conversion problem without adding any external dependencies. Edit: pathlib2 provides pathlib for Python 2.7 and is already on the requirements list to run the package tests.

@uvaisTrivecta As a temporary workaround, try the following:

  1. Extract your jar archive into a new subdirectory of your project folder.
  2. In your YAML template, replace the jar archive name with the name of the subdirectory you extracted it to.
  3. Give the Unix-style path to your project folder as the value of --docker-volume-basedir in your sam local start-api call as before.

@uvaisTrivecta
Copy link
Author

uvaisTrivecta commented Jul 10, 2018

@bryanburke many thanks for the response

as u said , i tried the temp work around , but still the same issue exists 👎

Yaml File :

changed from
CodeUri: target/serverless-spring-example-1.0-SNAPSHOT.jar
to
CodeUri: serverless-spring-example-1.0-SNAPSHOT

A screen shot of my directory structure

image

Log :
Lenovo2@New MINGW64 /e/AwsLambda/aws-serverless-java-container/samples/spring/pet-store (master)
$ MSYS2_ARG_CONV_EXCL="*" sam local start-api --template sam.yaml --docker-volume-basedir /e/AwsLambda/aws-serverless-java-container/samples/spring/pet-store
2018-07-10 12:23:11 Mounting PetStoreFunction at http://127.0.0.1:3000/{proxy+} [GET, DELETE, PUT, POST, HEAD, OPTIONS, PATCH]
2018-07-10 12:23:11 You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2018-07-10 12:23:11 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-07-10 12:23:14 Invoking com.amazonaws.serverless.sample.spring.StreamLambdaHandler::handleRequest (java8)
2018-07-10 12:23:14 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:java8 Docker container image......
2018-07-10 12:23:18 Mounting /e/AwsLambda/aws-serverless-java-container/samples/spring/pet-store/serverless-spring-example-1.0-SNAPSHOT as /var/task:ro inside runtime container
←[32mSTART RequestId: 9755d735-eff4-4c06-8b29-e9d25fd97615 Version: $LATEST←[0m
←[31mjava.lang.ClassNotFoundException: com.amazonaws.serverless.sample.spring.StreamLambdaHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
←[0m
←[32mEND RequestId: 9755d735-eff4-4c06-8b29-e9d25fd97615←[0m
←[32mREPORT RequestId: 9755d735-eff4-4c06-8b29-e9d25fd97615 Duration: 16.75 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 3 MB ←[0m
2018-07-10 12:23:22 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received:
2018-07-10 12:23:22 127.0.0.1 - - [10/Jul/2018 12:23:22] "GET /pets HTTP/1.1" 502 -
2018-07-10 12:23:22 Invoking com.amazonaws.serverless.sample.spring.StreamLambdaHandler::handleRequest (java8)
2018-07-10 12:23:22 Found credentials in shared credentials file: ~/.aws/credentials

Fetching lambci/lambda:java8 Docker container image......
2018-07-10 12:23:26 Mounting /e/AwsLambda/aws-serverless-java-container/samples/spring/pet-store/serverless-spring-example-1.0-SNAPSHOT as /var/task:ro inside runtime container
←[32mSTART RequestId: 052154b6-b11c-47ba-a80f-6ad5d109b25b Version: $LATEST←[0m
←[31mjava.lang.ClassNotFoundException: com.amazonaws.serverless.sample.spring.StreamLambdaHandler
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
←[0m
←[32mEND RequestId: 052154b6-b11c-47ba-a80f-6ad5d109b25b←[0m
←[32mREPORT RequestId: 052154b6-b11c-47ba-a80f-6ad5d109b25b Duration: 11.28 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 3 MB ←[0m
2018-07-10 12:23:31 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received:
2018-07-10 12:23:31 127.0.0.1 - - [10/Jul/2018 12:23:31] "GET /favicon.ico HTTP/1.1" 502 -

@badluck1024
Copy link

The same error for me... :(

@syeds-git
Copy link

argh stuck with same issue. I am on Windows 7. Are there any updates to this?

@Zeeeeta
Copy link

Zeeeeta commented Aug 2, 2018

Same issue here making us cannot use sam local on Windows 7.

Tried bryanburke's local_lambda.py hack and ran into ClassNotFoundException as well :(

@jfuss jfuss added the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Sep 10, 2018
@zuifanzhuce
Copy link

zuifanzhuce commented Sep 12, 2018

Faced the same issue "invalid volume specification" on Win 7, then I got the following after hacking local-lambda.py.

C:\Users{username}\sam-app>sam local start-api --docker-volume-basedir /c/Users/{username}/sam-app
2018-09-12 15:04:21 Invoking app.lambda_handler (python3.6)
2018-09-12 15:04:21 Found credentials in shared credentials file: ~/.aws/credent
ials

Fetching lambci/lambda:python3.6 Docker container image......
2018-09-12 15:04:26 Mounting /c/Users/sam-app/hello_world/build/ as /va
r/task:ro inside runtime container
START RequestId: d366fd5d-4c69-4ca1-bada-64b68741ffbb Version: $LATEST
Unable to import module 'app': No module named 'app'
END RequestId: d366fd5d-4c69-4ca1-bada-64b68741ffbb
REPORT RequestId: d366fd5d-4c69-4ca1-bada-64b68741ffbb Duration: 1 ms Billed Dur
ation: 100 ms Memory Size: 128 MB Max Memory Used: 19 MB
2018-09-12 15:04:29 Function 'HelloWorldFunction' timed out after 3 seconds

@sriram-mv
Copy link
Contributor

Make sure your directory on the host machine is shared with docker. Maybe try moving it to
/c/Users/{username}/sam-app and see it it helps? if not sharing needs to be setup correctly.

@zuifanzhuce
Copy link

Changed the shared folder setting, no problem finding the module now. But still got the error "invalid volume specification" once accessing http://127.0.0.1:3000/hello

$ sam local start-api --docker-volume-basedir /c/Users/{username}/sam-app
2018-09-14 14:56:13 Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [
GET]
2018-09-14 14:56:13 You can now browse to the above endpoints to invoke your fun
ctions. You do not need to restart/reload SAM CLI while working on your function
s changes will be reflected instantly/automatically. You only need to restart SA
M CLI if you update your AWS SAM template
2018-09-14 14:56:14 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-09-14 14:56:37 Invoking app.lambda_handler (python3.6)
2018-09-14 14:56:41 Starting new HTTP connection (1): 169.254.169.254

Fetching lambci/lambda:python3.6 Docker container image......
2018-09-14 14:56:46 Mounting C:/Users/{username}/sam-app/hello_world/build/ as /va
r/task:ro inside runtime container
2018-09-14 14:56:46 Exception on /hello [GET]
Traceback (most recent call last):
File "c:\python36\lib\site-packages\docker\api\client.py", line 229, in _raise
_for_status
response.raise_for_status()
File "c:\python36\lib\site-packages\requests\models.py", line 935, in raise_fo
r_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
https://192.168.99.100:2376/v1.35/containers/create

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\python36\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "c:\python36\lib\site-packages\flask\app.py", line 1815, in full_dispatch
_request
rv = self.handle_user_exception(e)
File "c:\python36\lib\site-packages\flask\app.py", line 1718, in handle_user_e
xception
reraise(exc_type, exc_value, tb)
File "c:\python36\lib\site-packages\flask_compat.py", line 35, in reraise
raise value
File "c:\python36\lib\site-packages\flask\app.py", line 1813, in full_dispatch
_request
rv = self.dispatch_request()
File "c:\python36\lib\site-packages\flask\app.py", line 1799, in dispatch_requ
est
return self.view_functionsrule.endpoint
File "c:\python36\lib\site-packages\samcli\local\apigw\local_apigw_service.py"
, line 140, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream,
stderr=self.stderr)
File "c:\python36\lib\site-packages\samcli\commands\local\lib\local_lambda.py"
, line 80, in invoke
self.local_runtime.invoke(config, event, debug_context=self.debug_context, s
tdout=stdout, stderr=stderr)
File "c:\python36\lib\site-packages\samcli\local\lambdafn\runtime.py", line 79
, in invoke
self._container_manager.run(container)
File "c:\python36\lib\site-packages\samcli\local\docker\manager.py", line 61,
in run
container.create()
File "c:\python36\lib\site-packages\samcli\local\docker\container.py", line 12
0, in create
real_container = self.docker_client.containers.create(self._image, **kwargs)

File "c:\python36\lib\site-packages\docker\models\containers.py", line 824, in
create
resp = self.client.api.create_container(**create_kwargs)
File "c:\python36\lib\site-packages\docker\api\container.py", line 411, in cre
ate_container
return self.create_container_from_config(config, name)
File "c:\python36\lib\site-packages\docker\api\container.py", line 422, in cre
ate_container_from_config
return self._result(res, True)
File "c:\python36\lib\site-packages\docker\api\client.py", line 235, in _resul
t
self._raise_for_status(response)
File "c:\python36\lib\site-packages\docker\api\client.py", line 231, in _raise
for_status
raise create_api_error_from_http_exception(e)
File "c:\python36\lib\site-packages\docker\errors.py", line 31, in create_api

error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("invalid volume
specification
: 'C:/Users/{username}/sam-app/hello_world/build/:/var/task:ro'")
2018-09-14 14:56:47 127.0.0.1 - - [14/Sep/2018 14:56:47] "GET /hello HTTP/1.1" 5
02 -
2018-09-14 14:56:47 127.0.0.1 - - [14/Sep/2018 14:56:47] "GET /favicon.ico HTTP/
1.1" 403 -

@jfuss
Copy link
Contributor

jfuss commented Sep 14, 2018

@zuifanzhuce You are mounting a windows path. From your output:
2018-09-14 14:56:46 Mounting C:/Users/{username}/sam-app/hello_world/build/ as /va r/task:ro inside runtime container. This is why you are seeing invalid volume specification. We have a fix merged into develop and waiting for a release.

@sriram-mv
Copy link
Contributor

yes, if you really want to experiment, you can still build sam directly from github develop branch as there's a fix merged in there.

@jfuss
Copy link
Contributor

jfuss commented Oct 24, 2018

Closing. Was released with 0.6.1

@jfuss jfuss closed this as completed Oct 24, 2018
@afinzel
Copy link

afinzel commented Nov 17, 2018

I know this is closed but if anyone still gets this, check your docker is running in linux mode and not windows by right clicking on docker and click "Switch to Linux containers"

@ratanudit
Copy link

Hi, I am still facing this issue.
It asks me to share the C:\ Drive, I give my credentials and then it gets stuck here:
Fetching lambci/lambda:java8 Docker container image......
2018-11-22 15:37:37 Mounting C:\Users\UDITRA~1.KAS\AppData\Local\Temp\tmp4q6jder0 as /var/task:ro inside runtime container

Also the command docker run hello world is not running after providing docker id.

Would appreciate a quick help, as we are encountering this issue from past two weeks. All troubleshooting is done, but still no success :(

Appreciate your help!

@foufos
Copy link

foufos commented Feb 4, 2019

Hi,
I had the same issue with docker in windows (linux was ok)
I managed to bypass this by getting the path from the docker inspect command

custom-entrypoint.sh
#!/bin/bash

#find the current running container
CURCONTAINER=$(docker ps | grep -w samapp_local | awk '{print $1}')
#find the source path of the volume mounted on /var/opt
HOSTPATH=$(docker inspect -f '{{range .Mounts}}{{if eq .Destination "/var/opt"}}{{.Source}}{{end}}{{end}}' $CURCONTAINER)

#start with the default ENTRYPOINT - CMD
/usr/local/bin/sam local start-api --docker-volume-basedir ${HOSTPATH}'/.aws-sam/build/' --host 0.0.0.0

Dockerfile
...
COPY ./test/custom-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/custom-entrypoint.sh

docker-compose.yaml
version: '2'
services:
web:
container_name: samapp_local
build: .
ports:
- "3000:3000"
environment:
- AWS_DEFAULT_REGION=eu-west-1
volumes:
- .:/var/opt:rw
- /var/run/docker.sock:/var/run/docker.sock
entrypoint: /usr/local/bin/custom-entrypoint.sh

@ermiaswalelgne
Copy link

I follow the steps outlined by @jfuss i.e uninstall docker toolkit and install Docker for windows.
and Got an error docker.errors.APIError: 500 Server Error: Internal Server Error ("error while creating mount source path '/host_mnt/c/Users/ . But it works perfectly when I run Windows PowerShell as Admin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests