我正在试图将一个容器附加到两个子网上,但没有成功。
这条信息报告目前不支持跨子网通信: https : //docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking
但是,我在大型默认NATnetworking中定义了两个自定义NAT子网。
启动容器时,一切看起来都不错:容器中有两个虚拟NIC,并带有相应的IP地址。 但是,我只能ping从主机和容器在各自的子网中的一个接口。
这是目前支持,应该工作?
这可能是一个选项之间路由两个分离的子网,是目前可以与Docker for Windows?
我尝试了两种networking创build方法:
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