DOCKER NETWORK CONNECT
Commande : docker network connect
Usage: docker network connect [OPTIONS] NETWORK CONTAINER Connect a container to a network Options: --alias strings Add network-scoped alias for the container --ip string IPv4 address (e.g., 172.30.100.104) --ip6 string IPv6 address (e.g., 2001:db8::33) --link list Add link to another container --link-local-ip strings Add a link-local address for the container
Connecter un container à un réseau existant :
docker network connect [OPTIONS] network container
ex :
$ docker container exec my_nginx ping new_nginx ping: bad address 'new_nginx' $ docker network connect mynet my_nginx $ docker network connect mynet new_nginx $ docker container exec my_nginx ping new_nginx PING new_nginx (172.18.0.3): 56 data bytes 64 bytes from 172.18.0.3: seq=0 ttl=64 time=0.084 ms 64 bytes from 172.18.0.3: seq=1 ttl=64 time=0.377 ms ^C $ docker container exec new_nginx ping my_nginx PING my_nginx (172.18.0.2): 56 data bytes 64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.076 ms 64 bytes from 172.18.0.2: seq=1 ttl=64 time=0.263 ms ^C