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?
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
.
DOCKER_HOST
env var. –
Bounds This solved it for me on Mac:
- Click the settings "cog" icon in the top right
- Open the "Advanced" section
- Tick "Allow the default Docker socket to be used"
- Click the "Apply and restart" button
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
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
~/.zshenv
–
Amarette ~/.bash_profile
–
Tucker 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.
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
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.
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
Go to Docker Desktop, then Settings/Advanced and if the "Allow the default Docker socket to be used (requires password)" option is checked, uncheck it, press "Apply & Restart" button and then check this option again and press "Apply & Restart" button again. It will install /var/run/docker.sock
Having same issue when working with Docker on macOS ($sam local start-api). But after change setting [Allow the default Docker socket to be used(required password)] in the "Advanced" menu in the desktop, It worked.
© 2022 - 2024 — McMap. All rights reserved.
docker.sock
lives under~/.docker/desktop
. – Dodds