When the container starts, it can only be connected to a single network, using --network. However, you can connect a running container to multiple networks using docker network connect
In terms of Docker, a bridge network uses a software bridge which allows containers connected to the same bridge network to communicate, while providing isolation from containers which are not connected to that bridge network. The Docker bridge driver automatically installs rules in the host machine so that containers on different bridge networks cannot communicate directly with each other.
Bridge networks apply to containers running on the same Docker daemon host. For communication among containers running on different Docker daemon hosts, you can either manage routing at the OS level, or you can use an overlay network.
When you start Docker, a default bridge network (also called bridge) is created automatically, and newly-started containers connect to it unless otherwise specified. You can also create user-defined custom bridge networks. User-defined bridge networks are superior to the default bridge network.
The overlay network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely. Docker transparently handles routing of each packet to and from the correct Docker daemon host and the correct destination container.
Some applications, especially legacy applications or applications which monitor network traffic, expect to be directly connected to the physical network. In this type of situation, you can use the macvlan network driver to assign a MAC address to each container’s virtual network interface, making it appear to be a physical network interface directly connected to the physical network.
With the network set to container a container will share the network stack of another container. The other container’s name must be provided in the format of --network container:<name|id>. Note that --add-host, --hostname, --dns, --dns-search, --dns-option, and--mac-addressare invalid in container netmode, and--publish,--publish-all,--expose` are also invalid in container netmode.
Docker
-p
: Port--dns
: DNS--net container:foo
--link
Articles, Projects, etc
Note: Concepts/methods described in these articles are applicable beyond just downloading/torrenting.
--cap-add=NET_ADMIN --device /dev/net/tun --dns 8.8.8.8 --name vpn
--net=container:vpn