Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SAM CLI on Mac OS build does not work - cannot find docker

I'm trying to run sam build using the AWS SAM CLI, but run into a problem. I get the following error:

Build Failed
Error: Building image for DefaultFunction requires Docker. is Docker running?

It looks like docker cannot be found, although it is installed. When I run docker ps I see the confirmation that Docker is running. The weird thing is that the build command does actually work for my colleagues in the same project who are also using MacOS with Intel chip.

I have SAM CLI, version 1.60.0 installed

I have Docker version 20.10.20 installed and running

I'm running it on MacOS Montery 12.5

I've been looking for a answer to this problem for a while now, but couldn't find a solution. Does anyone know how to fix this? I've followed all steps from this documentation.

like image 932
Camille Sébastien Niessen Avatar asked Sep 02 '25 06:09

Camille Sébastien Niessen


1 Answers

This is due to certain recent versions of Docker for Mac breaking compatibility. Check this bug report. Apparently it has already been fixed in the latest version of Docker for Mac.

In the meantime, the following workaround (as specified in the above GitHub issue) works for me:

DOCKER_HOST=unix://$HOME/.docker/run/docker.sock sam local start-api
like image 192
schiavuzzi Avatar answered Sep 04 '25 21:09

schiavuzzi