windows - 将 Docker Windows WSL Ubuntu 连接到 VMware Ubuntu

标签 windows docker ubuntu windows-subsystem-for-linux

我正在尝试连接我的 Windows 10 Home 系统,以便能够运行完整的 Linux OS Docker 容器。我已经在 WSL Ubuntu 18.04 和 VMware Ubuntu 18.04 上安装了 Docker。

我试图关注 this guide .

但是,我在尝试按照说明配置守护程序时遇到了困难。

Can’t use Docker for Windows? This is only necessary if you are NOT running Docker for Windows!

No problem, just configure your Docker daemon to use -H tcp://0.0.0.0:2375 and --tlsverify=false. Then you can follow along with the rest of this guide exactly.

If you go down this route, I highly recommend rolling your own VM with VMware Player instead of using the Docker Toolbox because VirtualBox has crazy edge case shared folder bugs that will ruin your life at some point. Don’t worry, VMware Player is free. Just Google how to set up Ubuntu 16 server on VMware Player.



当我尝试通过创建 daemon.json 来更改 Docker 守护程序时文件我得到错误。我也试过编辑 .profile文件和 .bashrc根据 other guides ( another guide ),没有运气。

我无法检查 VM Ubuntu 上的 DOCKER_HOST 变量。

最佳答案

不要把事情复杂化。在您的情况下,如果您只想连接到远程守护程序,为什么要使用 WSL?为什么不简单地使用 windows docker 客户端呢?

  • 使用 docker 设置你最喜欢的本地虚拟机。
    示例:我安装了在本地 VMWare 工作站上运行的 CentOS 发行版。当然,所有 Hyper-V 都已卸载/停用。
  • 在此 VM 中,为守护程序启用 tcp 访问。
    如果你有一个 systemd linux 发行版(比如我的 CentOS),执行这个:
    sudo mkdir -p /etc/systemd/system/docker.service.d
    
    sudo echo '[Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375' >> /etc/systemd/system/docker.service.d/options.conf
    
    sudo systemctl daemon-reload
    sudo systemctl restart docker`
    
  • 使用 docker info 测试端口是否打开.您应该在底部结果中收到 API 访问警告。
  • 从此处下载 Windows docker cli zip:https://download.docker.com/win/static/stable/x86_64/
    将 docker.exe 移动到任何文件夹,例如。您的文档文件夹。
    然后将此文件夹路径放入您的 Windows PATH 变量中。
  • 设置docker主机:打开PowerShell,执行setx DOCKER_HOST <VM-IP>:2375并关闭它。
  • 打开一个新的 PowerShell 并调用 docker info .
    您应该会看到 docker 和 daemon 信息。

  • 现在做你喜欢做的事...... :-)

    关于windows - 将 Docker Windows WSL Ubuntu 连接到 VMware Ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52135336/

    相关文章:

    c# - 检测附加分析器

    Python 脚本不会通过在 Windows 上双击来执行

    java - 来自 java 的 Windows 性能计数器

    python - 皮斯坦 : CompileError: command 'gcc' failed with exit status 1 (Windows)

    amazon-web-services - Amazon ECR上的受限图像拉权限

    php - 在 docker php 容器中找不到 MySQLi

    Docker 卷挂载在 Azure DevOps Pipeline 中不起作用

    ubuntu - 无法重启 nginx 网络服务器

    java - 在 ubuntu 上启动 Spring boot 应用程序但花费太多时间

    ruby - AWS Codedeploy 代理需要运行 ruby​​ 2.x,您无法安装旧版本的 ruby​​(解决方法)