$ docker network ls
** sample output **
NETWORK ID NAME DRIVER SCOPE 0a34ec3a4f58 bridge bridge local 5452c8e97607 host host local d6a1ef964756 none null local
$ docker network inspect bridge
sample output:
[
{
"Name": "bridge",
"Id": "0a34ec3a4f58edd8aa7ad46bdd8946c9275a1f5b72c2bbc36d2e5ebfe6e836ee",
"Created": "2018-08-21T11:01:29.148832762Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16"
}
]
},
"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": {}
}
]
$ docker container run -d --name alpine1 alpine $ docker container run -d --name alpine2 alpine
$ docker network inspect bridge
sample output:
[
{
"Name": "bridge",
"Id": "0a34ec3a4f58edd8aa7ad46bdd8946c9275a1f5b72c2bbc36d2e5ebfe6e836ee",
"Created": "2018-08-21T11:01:29.148832762Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"5f4b98a4dfbd93807a3c0c8fd614a9102e253b79439c068c75bbc4f264464fad": {
"Name": "my_alpine",
"EndpointID": "7b602fd7b979fae9b46f809d813b7c54ad3e4250df73a388d79b8e47a9ceb899",
"MacAddress": "02:42:ac:11:00:02",
"IPv4Address": "172.17.0.2/16",
"IPv6Address": ""
},
"df230c9bc75b40cbd5ee4452c5fe3207c6decb25ecf33f93b29bf83111159821": {
"Name": "my_alpine2",
"EndpointID": "ef90389287f9dbaeae9f3c99f1742a14377ac3a19e3d1b633376f73ebcac235c",
"MacAddress": "02:42:ac:11:00:03",
"IPv4Address": "172.17.0.3/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": {}
}
]
$ docker container attach alpine2
within the container, checking network configuration and status:
/# ifconfig // check network interfaces /# route -n // check routing table /# ping www.google.com // check DNS /# ping /# ping /# ping alpine1
exits the alpine2 container using 'Ctrl+pq'.
$ docker network create net1 $ docker network ls NETWORK ID NAME DRIVER SCOPE 0a34ec3a4f58 bridge bridge local 5452c8e97607 host host local 9a4dde6f2498 net1 bridge local d6a1ef964756 none null local
$ docker network connect net1 alpine1 $ docker network connect net1 alpine2 $ docker network inspect net1
sample output:
[
{
"Name": "net1",
"Id": "9a4dde6f2498f46819c6e7d2da98c46e36d6ed5d866403be62aa54a8e99efc80",
"Created": "2018-08-21T11:20:49.992829738Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"5f4b98a4dfbd93807a3c0c8fd614a9102e253b79439c068c75bbc4f264464fad": {
"Name": "my_alpine",
"EndpointID": "7ab05e8cf5032311de3af4b89483810b7849946158600866d2ffde93836cdc8f",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"df230c9bc75b40cbd5ee4452c5fe3207c6decb25ecf33f93b29bf83111159821": {
"Name": "my_alpine2",
"EndpointID": "398d5704764628b2fc231dc8b81730819a47b483898873d96f8f3dc507660c83",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
Now attach the terminal to 'alpine2' container and test everything again. What are the difference?