无法连接到macOS上的Docker守护程序 [英] Cannot connect to the Docker daemon on macOS

查看:161
本文介绍了无法连接到macOS上的Docker守护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常更喜欢使用brew在OSX上管理我的应用

I normally prefer to manage my apps on my OSX with brew

我能够安装docker,docker-compose和docker-machine

I am able to install docker, docker-compose and docker-machine

docker --version
Docker version 17.05.0-ce, build 89658be
docker-compose --version
docker-compose version 1.13.0, build unknown
docker-machine --version
docker-machine version 0.11.0, build 5b27455

我没有下载并运行"Docker for Mac"应用.

I did not download and run 'Docker for Mac' app.

但是,当我尝试运行时

> docker run -d -p 80:80 --name webserver nginx
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

我已经检查了袜子文件

ls -lah /var/run/docker.sock /var/tmp/docker.sock
ls: /var/run/docker.sock: No such file or directory
ls: /var/tmp/docker.sock: No such file or directory

我也尝试了建议的解决方案:

I have also tried this proposed solution: Mac OS X sudo docker Cannot connect to the Docker daemon. Is the docker daemon running on this host?

但是我收到此错误消息:

But I got this error message:

$ eval $(docker-machine env default)
Host does not exist: "default"

是否可以通过命令行工具运行docker服务?

Is it possible to get a docker service to run by command line tools?

推荐答案

在受支持的Mac上,运行:

On a supported Mac, run:

brew cask install docker

然后启动 Docker 应用.点击下一步.它将要求特权访问.确认.鲸鱼图标应出现在顶部栏中.单击它,等待"Docker正在运行".

Then launch the Docker app. Click next. It will ask for privileged access. Confirm. A whale icon should appear in the top bar. Click it and wait for "Docker is running" to appear.

您现在应该可以运行docker命令:

You should be able to run docker commands now:

docker ps

由于docker是系统级软件包,因此无法使用brew install进行安装,而必须使用cask.

Because docker is a system-level package, you cannot install it using brew install, and must use the cask instead.

注意:此解决方案仅适用于CPU支持虚拟化的Mac(可能不包括旧Mac).

Note: This solution only works for Macs whose CPUs support virtualization, which may not include old Macs.

这篇关于无法连接到macOS上的Docker守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆