Inspeccionando redes
Ver redes disponibles a usar
# usar comando network para info de ayuda
docker network
# salida
Usage: docker network COMMAND
Manage networks
Commands:
connect Connect a container to a network
create Create a network
disconnect Disconnect a container from a network
inspect Display detailed information on one or more networks
ls List networks
prune Remove all unused networks
rm Remove one or more networks
# listar redes disponibles
docker network ls
#salida
NETWORK ID NAME DRIVER SCOPE
e8a56097f041 bridge bridge local
2c325b6f3a3c go-react-todo_default bridge local
57891919696c host host local
c0b942849c43 miniapi-node-rn_default bridge local
a35faff8cdf8 none null local
# inspeccionar tipo de red
docker network inspect bridge
#salida
[
{
"Name": "bridge",
"Id": "e8a56097f041f0fe69320f9d119be8a17c3aad81e8c2d20f4df35783e081b5d9",
"Created": "2020-03-08T20:14:08.096383017-06:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
# parte de interes props "IPAM"
# probar agregando un contenedor por defecto
# (docker container run -dit --network bridge ubuntu)
docker container run -dit ubuntu
2bba6a2c370dcfa7be6c8e7a2ad37238b40b66eef5ae556dc84d999f72e33df9
# inspeccionar red nuevamente
docker network inspect bridge
#salida en ejecucion nuevo contenedor
[
{
"Name": "bridge",
"Id": "e8a56097f041f0fe69320f9d119be8a17c3aad81e8c2d20f4df35783e081b5d9",
"Created": "2020-03-08T20:14:08.096383017-06:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": { #new info
"2bba6a2c370dcfa7be6c8e7a2ad37238b40b66eef5ae556dc84d999f72e33df9": {
"Name": "trusting_brahmagupta",
"EndpointID": "f5b7efc97266d5a8da175117cdffbba8466b8166d5a0db60ce2080a77c2787b1",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
}
},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
# otra forma
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
2bba6a2c370d ubuntu "/bin/bash" 3 minutes ago Up 3 minutes
docker container inspect 2bba6a2c370d
# salida
[
{
"Id": "2bba6a2c370dcfa7be6c8e7a2ad37238b40b66eef5ae556dc84d999f72e33df9",
"Created": "2020-03-09T18:52:28.237349195Z",
"Path": "/bin/bash",
"Args": [],
"State": {
...
},
...
"HostConfig": {
...
},
"GraphDriver": {
...
},
"Mounts": [],
"Config": {
...
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "9065ed75f1b874b3db78e09cc92ca9dd1a2e3f908f432ef0640cf9474117125f",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/9065ed75f1b8",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "f5b7efc97266d5a8da175117cdffbba8466b8166d5a0db60ce2080a77c2787b1",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": { # interest info
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "e8a56097f041f0fe69320f9d119be8a17c3aad81e8c2d20f4df35783e081b5d9",
"EndpointID": "f5b7efc97266d5a8da175117cdffbba8466b8166d5a0db60ce2080a77c2787b1",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]Desconectar o conectar contenedor de alguna red
Agregar contenedor a otro tipo de red
Última actualización
¿Te fue útil?