Mac and Docker Desktop: “Cannot connect to the Docker daemon”

Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
  in github.com/supabase/cli/internal/utils.AssertDockerIsRunning:48
  in github.com/supabase/cli/internal/start.Run:37
Try rerunning the command with --debug to troubleshoot the error.

Why is this happening?

  • Macs are weird about Docker Desktop, make sure Docker is running
  • Run “$ docker ps” works and “$ docker info” to ensure docker is running.

Solution: Run this command to create a symbolic link inside of the “/var” directory

$ sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock

Source: https://github.com/nektos/act/issues/1658

Deep dive: Here’s a breakdown of the command and its components:

  • sudo: It’s a command that allows you to execute another command with administrative privileges. It’s often used when the command requires root or superuser access.
  • ln: It’s the command used to create links between files. In this case, we’re creating a symbolic link.
  • -s: It’s an option passed to the ln command to create a symbolic link. Without this option, ln would create a hard link instead.
  • ~/.docker/run/docker.sock: It’s the source file or directory for the link. In this case, it refers to the docker.sock file located within the ~/.docker/run/ directory in the user’s home directory (~ represents the home directory).
  • /var/run/docker.sock: It’s the destination path for the symbolic link. By creating the symbolic link, it allows programs or services that expect the Docker socket file to be available at /var/run/docker.sock to access it through ~/.docker/run/docker.sock instead.