user3461653
user3461653

Reputation: 71

docker up and running on my Mac but "sam local invoke" command results in Error: Running AWS SAM projects locally requires Docker

I have Docker up and running on my Mac. But "sam local invoke" command results in Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?

Anyone knows what could be the reason?

Upvotes: 7

Views: 3393

Answers (2)

Andrés Alba
Andrés Alba

Reputation: 141

I installed Docker using the GUI with all default presets and I was having the same issue. I fixed this same issue using Docker's dashboard.

Settings -> Advanced -> Allow the default Docker socket to be used (requires password)

By enabling it, it "Creates /var/run/docker.sock which some third-party clients may use to communicate with Docker Desktop"

Upvotes: 12

Michael Chun
Michael Chun

Reputation: 111

There was a change Docker Desktop's default context settings.

On Mac, it may default to desktop-linux if symlink to /var/run/docker.sock was not created. This seems to cause problem with SAM CLI (and probably, a lot of other apps) that expects to communicate with Docker using this socket.

The easiest way to fix this is to set DOCKER_HOST environment variable to point to the socket file associated with desktop-linux.

Run export DOCKER_HOST="unix://Users/<username>/.docker/run/docker.sock"

(add this to your .zshrc or .bashrc file so that you don't have to define the variable every time you start a shell)

and then try running sam command.

Upvotes: 11

Related Questions