Estou testando o Docker (1.12.2-cs2-ws-beta, compilação 050b611) no Windows Server 2016 e não consigo me conectar ao meu contêiner. Eu já percebi que o meu contêiner não tem um gateway padrão atribuído a ele. Como posso obter meu contêiner para pegar o gateway padrão?
Inspecionando a rede NAT, o gateway padrão foi fornecido:
PS C:\Users\Administrator> docker network inspect 32ccb769f85a
[
{
"Name": "nat",
"Id": "32ccb769f85ac73c317066dbe29f8c7cbf41b784c3dca6be9ac496285ae39d76",
"Scope": "local",
"Driver": "nat",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.20.128.0/20",
"Gateway": "172.20.128.1"
}
]
},
"Internal": false,
"Attachable": false,
"Containers": {
"4cd832e9b613d0756af4d85e895d5e01af7f7afe4710ba3229e056d9955e1c75": {
"Name": "webappbasic1-task-5d5c5892-1ff2-bc18-72ae-bdda56a2ea27",
"EndpointID": "74eee15c87551b3a213e94c1f05e337d733fceddb78849eb1b59336fa62a831d",
"MacAddress": "00:15:5d:e6:0f:d1",
"IPv4Address": "172.20.140.160/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.windowsshim.hnsid": "3acfc61d-0d8e-438c-8857-9c2b742707bf",
"com.docker.network.windowsshim.networkname": "nat"
},
"Labels": {}
}
]
Inspecionando o contêiner, o gateway padrão está ausente:
PS C:\Users\Administrator> docker inspect 4cd832e9b613
...
"Networks": {
"nat": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "32ccb769f85ac73c317066dbe29f8c7cbf41b784c3dca6be9ac496285ae39d76",
"EndpointID": "74eee15c87551b3a213e94c1f05e337d733fceddb78849eb1b59336fa62a831d",
"Gateway": "",
"IPAddress": "172.20.140.160",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:e6:0f:d1"
}
}
Eu tentei excluir e recriar a rede NAT, mas o problema persiste. Eu fiz isso através dos seguintes comandos:
Stop-Service -Name "docker"
Get-ContainerNetwork | Remove-ContainerNetwork
Created 'C:\ProgramData\Docker\config\daemon.json' with the following content:
{
"bridge": "none"
}
Start-Service -Name "docker"
docker network create -d nat --subnet=192.168.1.0/24 --gateway=192.168.1.1 MyNatNetwork
docker run -itd --network "MyNatNetwork" --rm <image_name>
E mais uma vez inspecionando meu contêiner:
"Networks": {
"MyNatNetwork": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"bdd983323dbd"
],
"NetworkID": "8fc6b7710ebe0b48f2d7657449cb5f6a06c78ad5544e869c94d238c4e9e452e6",
"EndpointID": "480dffc3cdb9058c1b3ca5b9091876a5b234592eba4d4ee851279381a5ad2790"
"Gateway": "",
"IPAddress": "192.168.1.121",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "00:15:5d:22:47:4a"
}
}