beyond-sw-camp / be01-101

Beyond SW camp first player 101
17 stars 2 forks source link

docker network #33

Open pySatellite opened 4 months ago

pySatellite commented 4 months ago

https://docs.docker.com/engine/reference/commandline/network/

ls

$ docker network ls

create

$ docker network create pd24-bridge
d1b1444e9a9f10857c93a377f395a2ee03b2fa479385536b4a5ef3d8bb26fda6
$ docker network ls
NETWORK ID     NAME          DRIVER    SCOPE
20e3fe38ac56   bridge        bridge    local
7f935ea017dd   host          host      local
550a2b76d4ab   minikube      bridge    local
2b0f04bf7325   none          null      local
d1b1444e9a9f   pd24-bridge   bridge    local

inspect

docker network inspect pd24-bridge
[
    {
        "Name": "pd24-bridge",
        "Id": "d1b1444e9a9f10857c93a377f395a2ee03b2fa479385536b4a5ef3d8bb26fda6",
        "Created": "2023-06-28T04:50:31.747246953Z",
        "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": {},
        "Options": {},
        "Labels": {}
    }
]
pySatellite commented 4 months ago

connect

$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                  NAMES
7fce1d34cad5   httpd-vi:1.0   "httpd-foreground"       56 minutes ago   Up 56 minutes   0.0.0.0:8051->80/tcp   httpd-1
1b65c56c4dc9   nginx:1.25.1   "/docker-entrypoint.…"   2 hours ago      Up 2 hours      0.0.0.0:9050->80/tcp   nginx-0
251bf137d021   httpd:2.4.57   "httpd-foreground"       2 hours ago      Up 2 hours      0.0.0.0:8050->80/tcp   httpd-0
$ docker network connect pd24-bridge httpd-1
$ docker network connect pd24-bridge httpd-0
$ docker network connect pd24-bridge nginx-0
$ docker network inspect pd24-bridge
[
    {
        "Name": "pd24-bridge",
        "Id": "d1b1444e9a9f10857c93a377f395a2ee03b2fa479385536b4a5ef3d8bb26fda6",
        "Created": "2023-06-28T04:50:31.747246953Z",
        "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": {
            "1b65c56c4dc983ce39c6d7c4c8bb61b3c2129e7726fd12a40020230fe30f6012": {
                "Name": "nginx-0",
                "EndpointID": "56c66c87dc0d66a48e04a22797845dc3889b6fb63ab06ac62822ce8fbd3f5d1b",
                "MacAddress": "02:42:ac:12:00:04",
                "IPv4Address": "172.18.0.4/16",
                "IPv6Address": ""
            },
            "251bf137d021d914353ca09e9ff88474901686c173efe585301262799d76f810": {
                "Name": "httpd-0",
                "EndpointID": "57de2184a08d61501311b55213eada75efcb24675b43833ca1609bdc9f62aff9",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            },
            "7fce1d34cad5b725f06af242c4c6a8680243ddb3092fe7799abd4fbb8ca10dc6": {
                "Name": "httpd-1",
                "EndpointID": "0e049e80d73845b5eca7c630b5192bccfb08f74ce46b8a7e9a5705ad603f7cf6",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]
$