aws-sam-cli: APIError: 500 Internal Server Error - Invalid volume specification
Description: APIError: 500 Server Error: Internal Server Error (“invalid volume specification: ‘C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda:/var/task:ro’”)
OS Version:
Windows 10 Pro 64-bit
Docker Version:
$ docker version
Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24302
Built: Fri Mar 23 08:31:36 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.05.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.10.1
Git commit: f150324
Built: Wed May 9 22:20:42 2018
OS/Arch: linux/amd64
Experimental: false
Steps to reproduce the issue:
- Create the template.yaml and the api.py file
- Issue the
sam local start-api
command - Browser to http://127.0.0.1:3000
Observed result: APIError: 500 Server Error: Internal Server Error (“invalid volume specification: ‘C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda:/var/task:ro’”)
Expected result: Downgrading to version 0.2.11 fixes the issue.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Output of sam --version
:
C:\Users\moleary>sam --version
SAM CLI, version 0.3.0
Optional Debug logs:
Add --debug flag to command you are running
C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda>sam local start-api --debug
2018-05-12 22:29:49 local start-api command is called
2018-05-12 22:29:49 2 resources found in the template
2018-05-12 22:29:49 Found Serverless function with name='TestingFunction' and CodeUri='.'
2018-05-12 22:29:49 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:49 No config file found
2018-05-12 22:29:49 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:49 No config file found
2018-05-12 22:29:49 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:29:49 https://192.168.99.100:2376 "GET /v1.35/_ping HTTP/1.1" 200 2
2018-05-12 22:29:49 2 resources found in the template
2018-05-12 22:29:49 Found '1' API Events in Serverless function with name 'TestingFunction'
2018-05-12 22:29:49 Detected Inline Swagger definition
2018-05-12 22:29:49 Lambda function integration not found in Swagger document at path='/' method='get'
2018-05-12 22:29:49 Found '0' APIs in resource 'ServerlessRestApi'
2018-05-12 22:29:49 Removed duplicates from '0' Explicit APIs and '1' Implicit APIs to produce '1' APIs
2018-05-12 22:29:49 1 APIs found in the template
2018-05-12 22:29:49 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:49 No config file found
2018-05-12 22:29:49 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:49 No config file found
2018-05-12 22:29:49 Mounting TestingFunction at http://127.0.0.1:3000/ [GET]
2018-05-12 22:29:49 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-05-12 22:29:49 Local API Server starting up. Multi-threading = True
2018-05-12 22:29:49 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-05-12 22:29:59 Constructed String representation of Event to invoke Lambda. Event: {"body": null, "httpMethod": "GET", "resource": "/", "queryStringParameters": null, "requestContext": {"httpMethod": "GET", "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", "path": "/", "extendedRequestId": null, "resourceId": "123456", "apiId": "1234567890", "stage": "prod", "resourcePath": "/", "identity": {"accountId": null, "apiKey": null, "userArn": null, "cognitoAuthenticationProvider": null, "cognitoIdentityPoolId": null, "userAgent": "Custom User Agent String", "caller": null, "cognitoAuthenticationType": null, "sourceIp": "127.0.0.1", "user": null}, "accountId": "123456789012"}, "headers": {"X-Forwarded-Port": "3000", "Host": "localhost:3000", "X-Forwarded-Proto": "http", "Accept": "*/*", "User-Agent": "curl/7.55.1"}, "stageVariables": null, "path": "/", "pathParameters": null, "isBase64Encoded": false}
2018-05-12 22:29:59 Found one Lambda function with name 'TestingFunction'
2018-05-12 22:29:59 Invoking api.lambda_handler (python3.6)
2018-05-12 22:29:59 No environment variables found for function 'TestingFunction'
2018-05-12 22:29:59 Environment variables overrides data is standard format
2018-05-12 22:29:59 Loading AWS credentials from session with profile 'None'
2018-05-12 22:29:59 Loading variable profile from defaults.
2018-05-12 22:29:59 Loading variable config_file from defaults.
2018-05-12 22:29:59 Loading variable credentials_file from defaults.
2018-05-12 22:29:59 Loading variable data_path from defaults.
2018-05-12 22:29:59 Loading variable profile from defaults.
2018-05-12 22:29:59 Loading variable credentials_file from defaults.
2018-05-12 22:29:59 Loading variable config_file from defaults.
2018-05-12 22:29:59 Loading variable profile from defaults.
2018-05-12 22:29:59 Loading variable metadata_service_timeout from defaults.
2018-05-12 22:29:59 Loading variable profile from defaults.
2018-05-12 22:29:59 Loading variable metadata_service_num_attempts from defaults.
2018-05-12 22:29:59 Loading variable profile from defaults.
2018-05-12 22:29:59 Looking for credentials via: env
2018-05-12 22:29:59 Found credentials in environment variables.
2018-05-12 22:29:59 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:29:59 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:29:59 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:29:59 Resolving code path. Cwd=C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda, CodeUri=.
2018-05-12 22:29:59 Resolved absolute path to code is C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda
2018-05-12 22:29:59 Code C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda is not a zip/jar file
2018-05-12 22:29:59 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:59 No config file found
2018-05-12 22:29:59 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:59 No config file found
2018-05-12 22:29:59 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:29:59 https://192.168.99.100:2376 "GET /v1.35/images/lambci/lambda:python3.6/json HTTP/1.1" 200 None
2018-05-12 22:29:59 Looking for auth config
2018-05-12 22:29:59 No auth config in memory - loading from filesystem
2018-05-12 22:29:59 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:29:59 No config file found
2018-05-12 22:29:59 Looking for auth entry for 'docker.io'
2018-05-12 22:29:59 No entry found
2018-05-12 22:29:59 No auth config found
2018-05-12 22:30:02 https://192.168.99.100:2376 "POST /v1.35/images/create?tag=python3.6&fromImage=lambci%2Flambda HTTP/1.1" 200 None
Fetching lambci/lambda:python3.6 Docker container image......
2018-05-12 22:30:02 Mounting C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda as /var/task:ro inside runtime container
2018-05-12 22:30:02 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:30:02 https://192.168.99.100:2376 "POST /v1.35/containers/create HTTP/1.1" 500 121
2018-05-12 22:30:02 Container was not created. Skipping deletion
[2018-05-12 22:30:02,783] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Program Files\Python\Python27\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Program Files\Python\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:\Program Files\Python\Python27\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 80, in invoke
stdout=stdout, stderr=stderr)
File "C:\Program Files\Python\Python27\lib\site-packages\samcli\local\lambdafn\runtime.py", line 83, in invoke
self._container_manager.run(container)
File "C:\Program Files\Python\Python27\lib\site-packages\samcli\local\docker\manager.py", line 61, in run
container.create()
File "C:\Program Files\Python\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:\Program Files\Python\Python27\lib\site-packages\docker\models\containers.py", line 824, in create
resp = self.client.api.create_container(**create_kwargs)
File "C:\Program Files\Python\Python27\lib\site-packages\docker\api\container.py", line 410, in create_container
return self.create_container_from_config(config, name)
File "C:\Program Files\Python\Python27\lib\site-packages\docker\api\container.py", line 421, in create_container_from_config
return self._result(res, True)
File "C:\Program Files\Python\Python27\lib\site-packages\docker\api\client.py", line 231, in _result
self._raise_for_status(response)
File "C:\Program Files\Python\Python27\lib\site-packages\docker\api\client.py", line 227, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "C:\Program Files\Python\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\moleary\Workspace\personal\aws-quiz-bot\lambda:/var/task:ro'")
2018-05-12 22:30:02 127.0.0.1 - - [12/May/2018 22:30:02] "GET / HTTP/1.1" 502 -
Setting code_abs_path to the following (in local_lambda.py) fixes on line 106 fixes the drive mounting issue, but the path is used elsewhere to mount the api.py file I have configured in the template. This then fails also
# Implemented the follow hack for testing.
code_abs_path = "/" + code_abs_path.lower().replace(
'\\','/').replace(':','').lower()
Unable to import module ‘api’: No module named ‘api’
C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda>sam local start-api --debug
2018-05-12 22:39:27 local start-api command is called
2018-05-12 22:39:27 2 resources found in the template
2018-05-12 22:39:27 Found Serverless function with name='TestingFunction' and CodeUri='.'
2018-05-12 22:39:27 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:27 No config file found
2018-05-12 22:39:27 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:27 No config file found
2018-05-12 22:39:27 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:39:28 https://192.168.99.100:2376 "GET /v1.35/_ping HTTP/1.1" 200 2
2018-05-12 22:39:28 2 resources found in the template
2018-05-12 22:39:28 Found '1' API Events in Serverless function with name 'TestingFunction'
2018-05-12 22:39:28 Detected Inline Swagger definition
2018-05-12 22:39:28 Lambda function integration not found in Swagger document at path='/' method='get'
2018-05-12 22:39:28 Found '0' APIs in resource 'ServerlessRestApi'
2018-05-12 22:39:28 Removed duplicates from '0' Explicit APIs and '1' Implicit APIs to produce '1' APIs
2018-05-12 22:39:28 1 APIs found in the template
2018-05-12 22:39:28 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:28 No config file found
2018-05-12 22:39:28 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:28 No config file found
2018-05-12 22:39:28 Mounting TestingFunction at http://127.0.0.1:3000/ [GET]
2018-05-12 22:39:28 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-05-12 22:39:28 Local API Server starting up. Multi-threading = True
2018-05-12 22:39:28 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
2018-05-12 22:39:30 Constructed String representation of Event to invoke Lambda. Event: {"body": null, "httpMethod": "GET", "resource": "/", "queryStringParameters": null, "requestContext": {"httpMethod": "GET", "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", "path": "/", "extendedRequestId": null, "resourceId": "123456", "apiId": "1234567890", "stage": "prod", "resourcePath": "/", "identity": {"accountId": null, "apiKey": null, "userArn": null, "cognitoAuthenticationProvider": null, "cognitoIdentityPoolId": null, "userAgent": "Custom User Agent String", "caller": null, "cognitoAuthenticationType": null, "sourceIp": "127.0.0.1", "user": null}, "accountId": "123456789012"}, "headers": {"X-Forwarded-Port": "3000", "Host": "localhost:3000", "X-Forwarded-Proto": "http", "Accept": "*/*", "User-Agent": "curl/7.55.1"}, "stageVariables": null, "path": "/", "pathParameters": null, "isBase64Encoded": false}
2018-05-12 22:39:30 Found one Lambda function with name 'TestingFunction'
2018-05-12 22:39:30 Invoking api.lambda_handler (python3.6)
2018-05-12 22:39:30 No environment variables found for function 'TestingFunction'
2018-05-12 22:39:30 Environment variables overrides data is standard format
2018-05-12 22:39:30 Loading AWS credentials from session with profile 'None'
2018-05-12 22:39:30 Loading variable profile from defaults.
2018-05-12 22:39:30 Loading variable config_file from defaults.
2018-05-12 22:39:30 Loading variable credentials_file from defaults.
2018-05-12 22:39:30 Loading variable data_path from defaults.
2018-05-12 22:39:30 Loading variable profile from defaults.
2018-05-12 22:39:30 Loading variable credentials_file from defaults.
2018-05-12 22:39:30 Loading variable config_file from defaults.
2018-05-12 22:39:30 Loading variable profile from defaults.
2018-05-12 22:39:30 Loading variable metadata_service_timeout from defaults.
2018-05-12 22:39:30 Loading variable profile from defaults.
2018-05-12 22:39:30 Loading variable metadata_service_num_attempts from defaults.
2018-05-12 22:39:30 Loading variable profile from defaults.
2018-05-12 22:39:30 Looking for credentials via: env
2018-05-12 22:39:30 Found credentials in environment variables.
2018-05-12 22:39:30 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:39:30 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:39:30 Loading variable region from environment with value 'ap-southeast-2'.
2018-05-12 22:39:30 Resolving code path. Cwd=C:\Users\moleary\Workspace\personal\aws-quiz-bot\lambda, CodeUri=.
2018-05-12 22:39:30 Resolved absolute path to code is /c/users/moleary/workspace/personal/aws-quiz-bot/lambda
2018-05-12 22:39:30 Code /c/users/moleary/workspace/personal/aws-quiz-bot/lambda is not a zip/jar file
2018-05-12 22:39:30 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:30 No config file found
2018-05-12 22:39:30 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:30 No config file found
2018-05-12 22:39:30 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:39:30 https://192.168.99.100:2376 "GET /v1.35/images/lambci/lambda:python3.6/json HTTP/1.1" 200 None
2018-05-12 22:39:30 Looking for auth config
2018-05-12 22:39:30 No auth config in memory - loading from filesystem
2018-05-12 22:39:30 Trying paths: ['C:\\Users\\moleary\\.docker\\config.json', 'C:\\Users\\moleary\\.dockercfg']
2018-05-12 22:39:30 No config file found
2018-05-12 22:39:30 Looking for auth entry for 'docker.io'
2018-05-12 22:39:30 No entry found
2018-05-12 22:39:30 No auth config found
2018-05-12 22:39:34 https://192.168.99.100:2376 "POST /v1.35/images/create?tag=python3.6&fromImage=lambci%2Flambda HTTP/1.1" 200 None
Fetching lambci/lambda:python3.6 Docker container image......
2018-05-12 22:39:34 Mounting /c/users/moleary/workspace/personal/aws-quiz-bot/lambda as /var/task:ro inside runtime container
2018-05-12 22:39:34 Starting new HTTPS connection (1): 192.168.99.100
2018-05-12 22:39:34 https://192.168.99.100:2376 "POST /v1.35/containers/create HTTP/1.1" 201 90
2018-05-12 22:39:34 https://192.168.99.100:2376 "GET /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/json HTTP/1.1" 200 None
2018-05-12 22:39:34 https://192.168.99.100:2376 "GET /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/json HTTP/1.1" 200 None
2018-05-12 22:39:34 https://192.168.99.100:2376 "POST /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/start HTTP/1.1" 204 0
2018-05-12 22:39:34 Starting a timer for 3 seconds for function 'TestingFunction'
2018-05-12 22:39:34 https://192.168.99.100:2376 "GET /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/json HTTP/1.1" 200 None
2018-05-12 22:39:34 https://192.168.99.100:2376 "POST /containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/attach?stream=1&stdin=0&logs=1&stderr=1&stdout=1 HTTP/1.1" 101 0
START RequestId: b14fb7dd-8778-4222-addf-c8fa5b39d9e4 Version: $LATEST
Unable to import module 'api': No module named 'api'
END RequestId: b14fb7dd-8778-4222-addf-c8fa5b39d9e4
REPORT RequestId: b14fb7dd-8778-4222-addf-c8fa5b39d9e4 Duration: 1 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
2018-05-12 22:39:35 Starting new HTTPS connection (2): 192.168.99.100
2018-05-12 22:39:35 https://192.168.99.100:2376 "GET /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f/json HTTP/1.1" 200 None
2018-05-12 22:39:35 https://192.168.99.100:2376 "DELETE /v1.35/containers/9b8c08f660776b9d11fc96d265cf7969b4aa6902b3fab8a76bc0cd876c2af65f?force=True&link=False&v=False HTTP/1.1" 204 0
2018-05-12 22:39:35 No Content-Type given. Defaulting to 'application/json'.
2018-05-12 22:39:35 127.0.0.1 - - [12/May/2018 22:39:35] "GET / HTTP/1.1" 200 -```
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (6 by maintainers)
May I request that the team not ignore the issue, as it’s still happening with Docker Toolkit?
I’m with @iKadmium about not ignoring this issue once Docker for Windows is available only for Windows 10 Pro and Enterprise x64. Another versions still need to make use of Docker Toolkit.
Well, I upgraded to v.0.3.0. Then I had to setup Python 2.7, because I had Python 3.4 installed and aws-sam-cli wants 2.7. And after that finally when I got aws-sam-cli running I found out that actually it is not going to work because of this mount problem. Moving to Windows 10 to start using Docker for Windows instead of Docker Toolkit seems too much for me for today. So for now I have to downgrade to old npm version of aws-sam-local. Are there any chances new version of aws-sam-cli will work with Docker Toolkit?