From 4028c5079dd5a4ff209bf7a5ecdee3a895f466d7 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:14:32 +0100 Subject: [PATCH] network: multiple nets with --network Corrects a false statement that you can't connect to multiple networks with the `--network` flag. Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- content/network/_index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content/network/_index.md b/content/network/_index.md index 13dfc2da30..8b850e1ce4 100644 --- a/content/network/_index.md +++ b/content/network/_index.md @@ -139,8 +139,9 @@ A container receives an IP address out of the IP subnet of the network. The Docker daemon performs dynamic subnetting and IP address allocation for containers. Each network also has a default subnet mask and gateway. -When a container starts, it can only attach to a single network, using the `--network` flag. -You can connect a running container to additional networks using the `docker network connect` command. +You can connect a running container to multiple networks, +either by passing the `--network` flag multiple times when creating the container, +or using the `docker network connect` command for already running containers. In both cases, you can use the `--ip` or `--ip6` flags to specify the container's IP address on that particular network. In the same way, a container's hostname defaults to be the container's ID in Docker.