Go Docker SDK: Unable to connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

WBOY
Release: 2024-02-12 16:54:06
forward
1209 people have browsed it

Go Docker SDK:无法连接到位于 unix:///var/run/docker.sock 的 Docker 守护进程。 docker 守护进程是否正在运行?

Question content

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
Copy after login

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                                      
Copy after login

Workaround

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!