Member-only story
User-defined networks
You can create custom, user-defined networks, and connect multiple containers to the same network. Once connected to a user-defined network, containers can communicate with each other using container IP addresses or container names.
The following example creates a network using the bridge
network driver:
$ docker network create -d bridge my-net
Running a container in the created network:
$ docker run --network=my-net -itd --name=container3 busybox
👉 Container networks
In addition to user-defined networks, you can attach a container to another container’s networking stack directly, using the --network container:<name|id>
flag format.
The following flags aren’t supported for containers using the container:
networking mode:
--add-host
--hostname
--dns
--dns-search
--dns-option
--mac-address
--publish
--publish-all
--expose
👉 Published ports
By default, when you create or run a container using docker create
or docker run
, the container doesn't expose any…