Home > Article > Backend Development > Go Docker SDK: Unable to connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I want to connect to a docker server running on my local computer (apple m2). When I run docker ps
it starts all the running containers which means the docker server is running and I can verify this by going to docker desktop. But when I try to connect it via docker go sdk it fails to connect.
❯ go run main.go 2023/05/20 17:34:15 cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running? exit status 1
This is the output of the command docker context ls
:
❯ docker context ls NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock https://35.186.144.128 (default) swarm desktop-linux * moby unix:///Users/xencodes/.docker/run/docker.sock
I fixed the issue by going to Docker Settings > Advanced and enabling Docker sock.
The above is the detailed content of Go Docker SDK: Unable to connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. For more information, please follow other related articles on the PHP Chinese website!