I am trying to run an AWS Lambda project locally on Ubuntu. When I run the project with AWS SAM Local it shows me this error: Error: Running AWS SAM projects locally requires Docker. Have you got it installed?

- 2,088
- 3
- 30
- 41

- 475
- 1
- 4
- 10
7 Answers
Another cause for this is this recent issue within Docker for Mac.
A quick workaround, as specified in the issue itself, is to run SAM with:
$ DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-api
You don't need to run SAM as root
.

- 764
- 4
- 9
-
I have Docker Desktop installed on Linux. This worked with a slight modification, since `docker.sock` lives under `~/.docker/desktop`. – Carlos Hanson Jan 26 '23 at 00:20
-
This worked for me 22/3/23 on a Mac with up-to-date docker installed and available on the CL. – JohnAllen Mar 22 '23 at 14:08
I had trouble installing it on Fedora.
When I followed the Docker postinstall instructions I managed to get past this issue.
https://docs.docker.com/install/linux/linux-postinstall/
I had to:
- Delete the ~/.docker directory;
- Create the "docker" group;
- Add my user to the "docker" group;
- Logout and back in again;
- Restart the "docker" daemon.
I was then able to run the command:
sam local start-api

- 241
- 2
- 4
-
4In Ubuntu 18 I just needed to add my user in the "docker" group (It was already created) and that was all – JDC Aug 08 '18 at 20:19
-
If you want to run local sam-cli
, you have first install docker from docker official website then run sudo sam local start-api
. Note that sudo is necessary for running local developer with needed privileges.

- 4,473
- 3
- 32
- 37
-
1
-
It should have to do with docker having to be invoked with sudo. I think that as of docker version 19 one can run it sudoless, but there are some caveats. All this is just a guess though. – geo909 Apr 22 '20 at 09:50
This error mostly arises due to lack of admin privilege to use docker. Just add sudo to your command. This will work.
eg: sudo sam local start-api --region eu-west-3

- 935
- 2
- 8
- 26
I am using colima for docker on mac with intel chip. and faced this error. was able to resolve it by adding DOCKER_HOST
in .zshrc
file
vi ~/.zshrc
paste export DOCKER_HOST="unix://$HOME/.colima/docker.sock"
in the .zshrc file
escape
:wq

- 13,461
- 8
- 60
- 73
We are working on Mac and were seeing same message when using an older version of Docker (1.12.6). Have since updated to a newer (but not latest) version 17.12.0-ce-mac49 and it is now fine.

- 91
- 2
-
Absolutely. Upgrading Docker, Docker Desktop and (in my case) Rider and AWS Toolkit for Rider helped me solve that issue. – Christopher J. Jul 25 '22 at 10:25
For those with Macs and using colima for docker, check two things:
~/.zshrc or ~/.bashrc have DOCKER_HOST pointed to
unix://$HOME/.colima/docker.sock"
, likeexport DOCKER_HOST="unix://$HOME/.colima/docker.sock"
Make sure colima is actually running.
colima start

- 21
- 6