ubuntu - 如何在 Windows 应用程序的 ubuntu 中运行 docker?

标签 ubuntu docker windows-subsystem-for-linux

我希望能够在 ubuntu on widnows app 中运行 docker .但是安装docker工具箱后,出现如下错误:

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

有没有人见过这个错误?在 Windows 上本地运行 docker 会更好吗?

最佳答案

您的 Docker 客户端不知道您的 Docker 主机(详尽解释here)。

You need to tell the Docker client where the Docker host is, and you can do that by using the -H option:

$ docker -H localhost:2375 一些 docker 命令

如果你不想每次都输入主机,你可以将名为DOCKER_HOST的环境变量设置为localhost:2375

$ export DOCKER_HOST=localhost:2375

但是,该环境变量只会在 session 进行时持续存在。每次打开 bash 时都必须设置它。因此,为了避免这种情况,您可以在主目录中名为 .bash_profile 的文件中设置该变量,如下所示:

$ echo “export DOCKER_HOST=localhost:2375” >> ~/.bash_profile

还要确保在 Windows 上公开守护程序,您可以在 Docker for Windows 的 Settings 菜单(选项卡“General”)中实现。

重新启动 bash 控制台,DOCKER_HOST 变量应该在那里,只需键入 e。 G。 docker images 检查所有内容。

关于ubuntu - 如何在 Windows 应用程序的 ubuntu 中运行 docker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49601842/

相关文章:

docker - 如何使 docker 网络——使用管道添加的接口(interface)持久化

node.js - 无法使用 Node :alpine 在 Docker 容器中运行 React 应用程序的开发版本

postgresql - WSL2 Ubuntu 无法ping通本地ip

docker - Owasp zap 中基于 header 的身份验证

python - 导入 Turicreate 出现错误 No module named 'turicreate.cython.cy_unity'

git - 适用于 Linux 的 Windows 子系统 git mergetool 融合了 UnicodeDecodeError

ubuntu - 启用 docker 容器之间的广播

ubuntu - 单击按钮从另一个事件中的事件返回 React-native

ubuntu - VMware 错误 "Unable to change power state of virtual machine UPS: Operation inconsistent with current state"

python - 由于 Ubuntu Vagrant Box 中的 locale.error,无法安装 pip 包