Create and inspect Docker custom networks
Lab prerequisites
Use an approved, disposable Linux Docker Engine VM with no external network access, ordinary bridge/NAT settings, and Engine 28.0.0 or later for publication labs. Verify the local context, server version, and that all bm-v05 names used in this example are unused. Use a reviewed, preloaded busybox:1.37 image; record its digest and check that httpd, wget and nslookup are present where used. The tag is not immutable. Run commands individually, stop on unexpected failure, and clean up only resources you created. Results below are expected, not observed. Before contacting the Engine, verify the effective local endpoint including DOCKER_HOST, DOCKER_CONTEXT and CLI overrides. Recheck the approved local image ID and native platform; if the recorded digest is unavailable, report it as unknown rather than inventing one. Use owner-set resource and time limits. If prerequisites cannot be confirmed, do the paper exercise instead. The VM must have no other untrusted workloads, no external routes and no direct-routing exceptions. A loopback mapping or internal bridge alone does not provide these guarantees. Use only a patched, supported Engine release meeting the stated minimum.
Group related containers
Instead of putting unrelated apps on one shared bridge, create a named network per application group. A container joins a network with --network NAME. Docker assigns addresses; the beginner need not choose a subnet. The --internal flag restricts external connectivity for this isolated exercise. It is not a complete hostile-code security boundary and does not guarantee isolation from the host.
Create and inspect membership
Create a fresh internal network and one container. Network IDs and assigned addresses are environment-specific. Stop if a resource name is already in use; never remove another resource to resolve a collision. Check the approved network address pool for overlap with existing VM routes; if the owner cannot confirm it, use the paper plan. Record the returned network ID and verify membership before deletion.
docker network create --driver bridge --internal bm-v05-custom-netdocker run -d --pull=never --name bm-v05-custom --network bm-v05-custom-net busybox:1.37 sleep 120docker network inspect --format '{{.Driver}} {{.Internal}}' bm-v05-custom-netdocker network inspect --format '{{range .Containers}}{{.Name}}{{end}}' bm-v05-custom-netExpected configuration: bridge true, with bm-v05-custom listed as a member while running.
Clean up in dependency order
Remove the lab container before removing the network. An attached endpoint can prevent removal; inspect the membership rather than forcing deletion or pruning networks. If sleep has already ended, skip stop. Do not disconnect unrelated endpoints.
docker stop bm-v05-customdocker rm bm-v05-customdocker network rm bm-v05-custom-netExpected: only the lab container and its network are gone. If network removal fails, inspect remaining membership and stop if any member is not yours.
Manual practice
Plan separate networks for a fictional web application and an unrelated demo. Explain what must be removed before deleting each network.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Create and inspect Docker custom networks — Knowledge check
Apply the concepts from this lesson.
Which flag attaches a new container to a named network?
What does --internal request for a bridge network?
Why might network removal fail?