10
votes

I'm trying to test my hello world lambda function with aws-sam-cli using the following command in my project root folder:

sam local start-api --debug

This gives me the following output in the console:

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 version 18.03.1-ce, build 9ee9f40

Does anyone one have an idea why sam can't find docker?

3
Run which docker. Where does it say Docker is installed? - RyanWilcox
it returns /usr/bin/docker - J. Leander
may this quiestion helps you? - juanlumn
@juanlumn That seems to have fixed it, thanks! I'm not sure what the standard procedure is when a comment answers the question. Do you post it as a seperate answer so that I can accept it? - J. Leander
Just added an answer - juanlumn

3 Answers

11
votes

Follow these steps:

  1. Delete the ~/.docker directory
  2. Create the "docker" group
  3. Add my user to the "docker" group
  4. Logout and back in again
  5. Restart the "docker" daemon.

More info in the Docker postinstall instructions

1
votes

I had an older version of docker installed. Although docker was working fine, sam could not detect it properly.

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. Have you got it installed?

I removed the old version and re-installed the docker.io package (under Ubuntu). Then I started the docker daemon and the issue was fixed.

0
votes

When installing Docker in windows make sure to install the linux kernel update that you get from a prompt window after installation:

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.