适用于Windows的Docker - 网络:具有多个网络接口的容器

时间:2017-05-04 13:56:25

标签: windows networking docker windows-container

我正在尝试将容器附加到两个子网,但没有成功。

此信息报告当前不支持跨子网通信: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking

但是,我在大型默认NAT网络中定义了两个自定义NAT子网。

启动容器时,一切看起来都没问题:容器内有两个具有适当IP地址的虚拟NIC。 但是,我只能ping主机中的一个接口和相应子网中的容器。

目前是否支持,并且应该有效? 它可能是在两个隔离子网之间路由的选项,目前可以使用Docker for Windows吗?

我尝试过两种网络创建方法:

1. with docker-compose:

    version: '2.1'
    services:
       rabbitmq-c:
         image: ephortesys/rabbitmq:latest
         hostname: rabbitmq-c
         domainname: gecko.no
         mem_limit: 1g
         networks:
           - internal
           - external
    networks:
      internal:
        driver: nat
          driver: default
        ipam:
          config:
          - subnet: 172.24.1.0/24
            gateway: 172.24.1.1
      external:
        driver: nat
        ipam:
          driver: default
          config:
          - subnet: 172.24.2.0/24
            gateway: 172.24.2.1

**

2. with 'docker network create', and use these in docker.compose.yml:

docker network create --driver=nat --subnet=172.24.1.0/24 --gateway=172.24.1.1 net1  
docker network create --driver=nat --subnet=172.24.2.0/24 --gateway=172.24.2.1 net2

networks:
   internal:
     external:
      name: "net1"
   external:
     external:
      name: "net2"

更多信息:

C:\WINDOWS\system32> Get-NetNat


Name                             : SharedNAT
ExternalIPInterfaceAddressPrefix :
InternalIPInterfaceAddressPrefix : 172.24.0.0/20
IcmpQueryTimeout                 : 30
TcpEstablishedConnectionTimeout  : 1800
TcpTransientConnectionTimeout    : 120
TcpFilteringBehavior             : AddressDependentFiltering
UdpFilteringBehavior             : AddressDependentFiltering
UdpIdleSessionTimeout            : 120
UdpInboundRefresh                : False
Store                            : Local
Active                           : True

C:\WINDOWS\system32> docker info
Containers: 1
 Running: 1
 Paused: 0
 Stopped: 0
Images: 18
Server Version: 17.03.1-ce
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 14393 (14393.1066.amd64fre.rs1_release_sec.170327-1835)
Operating System: Windows 10 Enterprise
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 63.84 GiB
Name: PC36144
ID: QYSA:VJE6:OM5A:EJE2:MFJ6:4XLV:UCDN:UTRF:TL5K:IWOO:O2O2:Y6Z3
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 30
 System Time: 2017-05-04T10:02:36.9325341+02:00
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false


C:\WINDOWS\system32> docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.24)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      windows/amd64
 Experimental: true

0 个答案:

没有答案