13

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?

J. Leander
  • 354
  • 1
  • 2
  • 12

6 Answers6

14

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

juanlumn
  • 6,155
  • 2
  • 30
  • 39
  • 1
    Important to log out and back in again for this to work. I read the linked instructions and thought a restart could be avoided but apparently not. – robjwilkins Dec 14 '22 at 11:32
2

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.

andrei
  • 1,009
  • 11
  • 16
1

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

https://learn.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.

  • Also, in Windows, before installing anything, it's useful to check if Docker itself is run. The easiest way to do this is to run Docker Desktop which in turn will run the necessary services. For me the error disappeared after this. – elshev Apr 18 '23 at 09:20
1

If this issue arises on Mac, I was able to solve this problem by implementing file sharing on the parent folder. AWS SAM requires file sharing to function, which presents this same error.

GarrettJ
  • 121
  • 2
0

I had the same issue on my M1 Mac and I had the docker desktop version 4.18.0. installed. I was able to solve my issue by downgrading docker to version 4.15.0.

0

I had the same issue because I accidentally ran the command

sam local start-api

without sudo. I just had to type it like

sudo sam local start-api

Maybe it will help somebody and prevent them from reinstalling docker.

Milena
  • 35
  • 5
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 10 '23 at 12:58