6.1.1.4 Creation Network Attachment
A focused guide to Creation Network Attachment, connecting core concepts with practical Docker and container operations.
Creation network attachment is the process by which a newly created container is connected to a Docker network, determining what other containers it can communicate with and how it can be reached from outside, configured at the moment the container is created unless otherwise changed afterward.
Default Network Attachment
Without explicit configuration, a newly created container is attached to Docker's default bridge network, providing basic network connectivity but without the more convenient name-based service discovery a user-defined network provides.
docker run -d --name myapp myapp:1.0
docker inspect myapp --format '{{json .NetworkSettings.Networks}}'
This reveals which network (the default bridge, unless otherwise specified) the container was attached to at creation.
Attaching to a Specific User-Defined Network
Explicitly specifying a network at creation time attaches the container to that network instead, enabling name-based communication with other containers also attached to it.
docker network create mynet
docker run -d --name db --network mynet postgres:16
docker run -d --name app --network mynet myapp:1.0
Both containers, attached to the same user-defined network, can reach each other by container name, which the default bridge network does not support.
Attaching to Multiple Networks
A container can be attached to more than one network, either at creation time or by explicitly connecting it to an additional network afterward.
docker network connect another-network myapp
Disabling Networking Entirely
For a container with no networking needs at all, network attachment can be explicitly disabled.
docker run -d --network none myapp:1.0
Why Creation Network Attachment Matters
The network a container is attached to at creation directly determines what it can communicate with — getting this configuration right, particularly choosing a user-defined network over the default bridge for multi-container applications, is essential for containers that genuinely need to talk to each other reliably by name.