如何在OSX上启动docker-machine?

9
我昨天第一次安装并使用了docker,一切正常,但昨晚我关闭了电脑。今天我启动电脑想要继续使用docker应用,但当我尝试运行以下命令时:docker run -d -p 8080:8080 container/app,出现了错误:

docker: 无法连接到Docker守护程序。此主机上是否正在运行Docker守护程序?

但我找不到如何重新启动docker... 有什么建议吗?编辑:
eval "$(docker-machine env default)"

结果:

TLS连接错误检查:主机未运行


https://github.com/docker/kitematic/issues/1010 - John Zwinck
已检查。 - F4Ke
3
docker-machine ls 命令会列出已配置的机器列表。如果某个机器已停止,运行 docker-machine start <machine名称> 启动它。请阅读文档 https://docs.docker.com/machine/overview/。 - thaJeztah
@thaJeztah - 你应该把你的评论发布为答案。在我看来,这是正确的解决方案。 - maml
@maml 嗯,是的,也许我应该这样做。 - thaJeztah
2个回答

9
docker-machine env <name-of-machine>.

如果“default”机器没有运行,“docker-machine env default”命令将无法工作。

您可以运行“docker-machine ls”命令,这应该会给您一个已配置的机器列表及其当前状态(正在运行、已停止)。

如果某个机器已停止,请运行“docker-machine start <name-of-machine>”。之后,您应该能够使用

docker-machine env <name-of-machine>设置环境变量。
eval "$(docker-machine env default)"

请查看https://docs.docker.com/machine/overview上的文档,以获取更多详细信息。

我运行了 docker-machine ls,然后执行了 docker-machine start <name-of-machine>,但我的电脑还是报错了,显示“运行SSH命令时出错!”。运行以下命令解决了这个问题: docker-machine restart 然后 eval "$(docker-machine env default)" - ali

1

当我运行命令$ docker-machine start default后,我收到以下信息:

Starting "default"...
(default) Check network to re-create if needed...
(default) Creating a new host-only adapter produced an error: /usr/local/bin/VBoxManage hostonlyif create failed:
(default) 0%...
(default) Progress state: NS_ERROR_FAILURE
(default) VBoxManage: error: Failed to create the host-only adapter
(default) VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
(default) VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
(default) VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg *)" at line 94 of file VBoxManageHostonly.cpp
(default) 
(default) This is a known VirtualBox bug. Let's try to recover anyway...
Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is supposed to fix this issue

在消息末尾提供了一个解决方案,保留HTML标记,请勿解释。
This is a known VirtualBox bug. Let's try to recover anyway...
Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is supposed to fix this issue

我卸载了VirtualBox,然后尝试重新安装。但问题仍然存在。
之后,我允许在机器上从任何地方下载应用程序,这解决了问题:
允许从任何地方下载应用程序:sudo spctl --master-disable

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接