Trying to run pack
to build a Cloud Native Buildpack on Mac, it fails, complaining about not finding the expected Docker socket, where it usually is:
pack build my-app --builder paketobuildpacks/builder:base
ERROR: failed to build: failed to fetch builder image 'index.docker.io/paketobuildpacks/builder:base':
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
But all docker CLI commands such as docker ps
work just fine. I am running Docker Desktop for Mac.
2
Answers
Explanation
The problem turns out to be that Docker Desktop uses a different socket. It works because the docker CLI is set automatically to use the correct "context"). See:
I too am running into this problem (with Docker Desktop for Mac), where
pack build ...
fails to connect b/c I have no/var/run/docker.sock
- but thedocker
CLI itself works just fine. Thhe docker context explains why it is the case:so the
default
context uses the standard socket but is not active and the socket does not exist. Instead, the active context isdesktop-linux
, which uses a socket in the user's home dir (which does exist).There is an open (3/2023) pack issue to use docker context to get the correct host automatically.
Solution
The solution then is to point pack to the correct socket:
To permanently fix the issue
echo export DOCKER_HOST=unix:///Users/kiplangatvictor/.docker/run/docker.sock >> ~/.zshrc
replace the .zsshrc with your respective file