简体   繁体   English

AWS Lambda Sam 找不到 docker

[英]AWS Lambda Sam can't find docker

I'm trying to test my hello world lambda function with aws-sam-cli using the following command in my project root folder:我正在尝试在我的项目根文件夹中使用以下命令使用aws-sam-cli测试我的 hello world lambda function:

sam local start-api --debug

This gives me the following output in the console:这在控制台中为我提供了以下 output :

2018-07-11 16:13:15 local start-api command is called
2018-07-11 16:13:15 2 resources found in the template
2018-07-11 16:13:15 Found Serverless function with name='Hello' and CodeUri='.'
2018-07-11 16:13:15 Trying paths: ['/home/jamiro/.docker/config.json', '/home/jamiro/.dockercfg']
2018-07-11 16:13:15 No config file found
2018-07-11 16:13:15 Trying paths: ['/home/jamiro/.docker/config.json', '/home/jamiro/.dockercfg']
2018-07-11 16:13:15 No config file found
Error: Running AWS SAM projects locally requires Docker. Have you got it installed?

To my understanding, I do have docker installed, as performing docker --version results in the following output:据我了解,我确实安装了 docker,因为执行docker --version会导致以下 output:

Docker version 18.03.1-ce, build 9ee9f40

Does anyone one have an idea why sam can't find docker?有谁知道为什么sam找不到 docker?

Follow these steps:按着这些次序:

  1. Delete the ~/.docker directory删除~/.docker目录
  2. Create the "docker" group创建“docker”组
  3. Add my user to the "docker" group将我的用户添加到“docker”组
  4. Logout and back in again注销并重新登录
  5. Restart the "docker" daemon.重新启动“docker”守护进程。

More info in the Docker postinstall instructions Docker 安装后说明中的更多信息

I had an older version of docker installed.我安装了旧版本的 docker。 Although docker was working fine, sam could not detect it properly.尽管 docker 工作正常,但 sam 无法正确检测到它。

sam local start-api --debug

docker.errors.APIError: 400 Client Error: Bad Request ("client is newer than server (client API version: 1.35, server API version: 1.24)") Error: Running AWS SAM projects locally requires Docker. docker.errors.APIError: 400 Client Error: Bad Request ("client is newer than server (client API version: 1.35, server API version: 1.24)") 错误:在本地运行 AWS SAM 项目需要 Docker。 Have you got it installed?你安装好了吗?

I removed the old version and re-installed the docker.io package (under Ubuntu).我删除了旧版本并重新安装了docker.io包(在 Ubuntu 下)。 Then I started the docker daemon and the issue was fixed.然后我启动了 docker 守护进程,问题就解决了。

When installing Docker in windows make sure to install the linux kernel update that you get from a prompt window after installation:在 Windows 中安装 Docker 时,请确保安装安装后从提示窗口获得的 linux 内核更新:

https://docs.microsoft.com/es-es/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package https://docs.microsoft.com/es-es/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package

After the update has been installed docker should restart (otherwise restart manually, or restart computer) and SAM should be able to find it ok.安装更新后 docker 应该重新启动(否则手动重新启动,或重新启动计算机),SAM 应该能够找到它。

If this issue arises on Mac, I was able to solve this problem by implementing file sharing on the parent folder.如果在 Mac 上出现此问题,我可以通过在父文件夹上实现文件共享来解决此问题。 AWS SAM requires file sharing to function, which presents this same error. AWS SAM 需要与 function 共享文件,这会出现同样的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM