我通常喜欢在我的OSX上用brew管理我的应用程序

我能够安装docker, docker-compose和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”应用程序。

然而,当我试图跑

> 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

我也尝试了这个建议的解决方案:Mac OS X sudo docker无法连接到docker守护进程。这个主机上是否运行docker守护进程?

但是我收到了这个错误信息:

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

有可能通过命令行工具来运行docker服务吗?


当前回答

我运行brew安装docker-machine;那么问题就解决了。最新版本的docker不包含docker-machine。

其他回答

尝试以下,它的工作现在很好

$ docker-machine create default
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet0"
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!

Then

$ docker-machine env default

最后

$ eval $(docker-machine env default)
$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

尝试这样创建默认值。

docker-machine create default

我在我的mac上也遇到了类似的问题,我发现docker没有在我的机器上运行,我只是去了应用程序,调用了whale,然后它就工作了。

我只需要运行spotlight搜索并在brew cask安装创建的/Applications文件夹下执行Docker应用程序。一旦运行,它要求完成安装。然后我就可以运行docker ps了

我也有同样的问题。Docker正在运行,但无法通过CLI访问它。

对我来说,这个问题是通过执行“Docker Quickstart Terminal.app”解决的。它位于“/Applications/Docker/”文件夹中。只要我在这个终端应用程序的实例中工作,Docker就可以完美地工作。如果需要第二个窗口,我必须再次运行“快速入门”应用程序。

我有一个用于Mac安装的Docker。因此,我不确定我的解决方案是否适用于Homebrew安装。

“Docker快速启动终端”应用程序似乎本质上是一些启动终端应用程序的applescripts和一个初始化所有必要环境变量的bash启动脚本。

希望这能帮助到其他人!