Santosh Silwal
Santosh Silwal

Reputation: 675

Running AWS SAM projects locally get error

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?

Upvotes: 46

Views: 45807

Answers (11)

Shyam Raghuwanshi
Shyam Raghuwanshi

Reputation: 21

I am in Arch-linux that's how i resolved my error

i reinstall the docker

wget https://download.docker.com/linux/static/stable/x86_64/docker-27.4.0.tgz -qO- | tar xvfz - docker/docker --strip-components=1
mv ./docker /usr/local/bin

and then install using the pacman

sudo pacman -S docker

then enable it

sudo systemctl enable docker

To avoid using sudo for Docker commands, add your user to the docker group

sudo usermod -aG docker $USER

Then reboot

sudo reboot

Upvotes: 0

Joe
Joe

Reputation: 21

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.

Upvotes: 2

David Marjanidze
David Marjanidze

Reputation: 41

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

Upvotes: 3

rangfu
rangfu

Reputation: 8977

This solved it for me on Mac:

  1. Click the settings "cog" icon in the top right
  2. Open the "Advanced" section
  3. Tick "Allow the default Docker socket to be used"
  4. Click the "Apply and restart" button

enter image description here

Upvotes: 39

Dave
Dave

Reputation: 31

For those with Macs and using colima for docker, check two things:

  1. ~/.zshrc or ~/.bashrc have DOCKER_HOST pointed to unix://$HOME/.colima/docker.sock", like export DOCKER_HOST="unix://$HOME/.colima/docker.sock"

  2. Make sure colima is actually running. colima start

Upvotes: 1

Akshay Vijay Jain
Akshay Vijay Jain

Reputation: 16025

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

Upvotes: 12

schiavuzzi
schiavuzzi

Reputation: 1072

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.

Upvotes: 41

ashique
ashique

Reputation: 1285

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

Upvotes: 4

Sagar
Sagar

Reputation: 4957

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.

Upvotes: 10

Stuart Reavell
Stuart Reavell

Reputation: 91

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.

Upvotes: 2

Dystopic64
Dystopic64

Reputation: 251

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:

  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.

I was then able to run the command:

sam local start-api

Upvotes: 15

Related Questions