首页 > 解决方案 > 如何将 aws sam cli 与卷一起使用 --docker-volume-basedir

问题描述

我在本地机器上启动了 sam,下面是目录结构

 - application (python3 code)
 - efs (got some files)
 - template-local.yaml

现在,我如何告诉 sam local 启动带有卷附加的 api。

我在命令下运行

sam local start-api \
  --template template-local.yaml \
  --docker-volume-basedir "/localmachine/project-folder/efs:/mnt/efs" \
  --profile otherAccount

容器成功运行,但是当我点击请求 localhost:3000 时,它会崩溃并出现以下错误

...
File "/usr/local/Cellar/aws-sam-cli/0.45.0/libexec/lib/python3.7/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: '/localmachine/project-folder/efs/application:/var/task:ro,delegated'")
2020-06-22 20:52:04 127.0.0.1 - - [22/Jun/2020 20:52:04] "GET /status HTTP/1.1" 502 -

AWS SAM cli doc https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html 没有提供有关卷安装的详细信息

有什么我做错了吗。

标签: aws-sam-climounted-volumes

解决方案


不幸的是,没有办法在 SAM 上安装外部卷。我正在尝试使用这个repo来构建一个里面有 sam 的 docker 并尝试堆和外部卷


推荐阅读