Docker for Windows:无法分配请求的地址

时间:2016-08-26 06:34:12

标签: windows networking docker

如何在Hyper-V上设置运行Docker 1.12的多主机?

我可以轻松分配一个127.x.x.x ip,但我想分配例如10.240.0.x。

这是我的docker-compose.yaml:

version: '2'
services:
  nginx:
    image: nginx:lastest
    ports:
      - "127.0.0.100:80:80"

如果我尝试分配10.240.0.100,我会收到此错误: 启动userland代理时出错:listen tcp 10.240.0.100:80:bind:无法分配请求的地址

我错过了什么?我是否必须配置Windows以支持这些地址?

1 个答案:

答案 0 :(得分:3)

这是使用Docker for Windows吗?有了这个,你只能将东西绑定到主机上的localhost

如果要在计算机上测试多节点群,则需要设置一组单独的VM:

> docker-machine create -d hyperv --hyperv-virtual-switch "Better New Virtual Switch" master
> docker-machine create -d hyperv --hyperv-virtual-switch "Better New Virtual Switch" worker1
> docker-machine create -d hyperv --hyperv-virtual-switch "Better New Virtual Switch" worker2

Init swarm:

> docker-machine inspect --format '{{ json .Driver.IPAddress }}' master
"192.168.202.112"
> docker-machine ssh master docker swarm init --advertise-addr 192.168.202.112
To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-1-4k5ljcmxs1d9q14lth4tfbg868lf8eqi5alxtvgo7s1ptyrhlu-3ihz3bfmx5622vei1smzetudf \
    192.168.202.112:2377

添加工人:

> docker-machine ssh worker1 docker swarm join --token SWMTKN-1-4k5ljcmxs1d9q14lth4tfbg868lf8eqi5alxtvgo7s1ptyrhlu-3ihz3bfmx5622vei1smzetudf 192.168.202.112:2377
> docker-machine ssh worker2 docker swarm join --token SWMTKN-1-4k5ljcmxs1d9q14lth4tfbg868lf8eqi5alxtvgo7s1ptyrhlu-3ihz3bfmx5622vei1smzetudf 192.168.202.112:2377

SSH进入主人并前往城镇(或从主人那里使用):

> docker-machine ssh master
> docker node ls
 ID                           HOSTNAME  STATUS  AVAILABILITY  MANAGER STATUS
 aojoo2h0uuj5hv1c9xajo67o2    worker1   Ready   Active
 eqt1yd8x52gph3axjkz8lxl1z *  master    Ready   Active        Leader

详细信息:https://github.com/docker/for-mac/issues/67#issuecomment-242239997