英文:
Go Docker SDK: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
问题
我想连接到在我的本地机器(Apple M2)上运行的Docker服务器。当我运行docker ps
时,它显示所有正在运行的容器,这意味着Docker服务器正在运行,并且我可以通过Docker桌面进行验证。但是,当我尝试通过Docker Go SDK连接时,它无法连接。
以下是命令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 want to connect to my Docker server running on my local machine (Apple M2). When I run docker ps
it shoes all the containers running which means Docker server is running, and I could verify that by going Docker desktop. But when I try to connect it via Docker Go SDK, it can't 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
Here is 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
答案1
得分: 1
我通过进入Docker设置 > 高级,并启用Docker sock来修复了它。
英文:
I have fixed it by going to Docker Settings > Advanced and enable Docker sock.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论