Port binding conflicts and container name collisions
Worked example
This is an offline lesson. Data are fictional and Docker commands are unexecuted. Any optional execution requires an authorized disposable VM, a verified context, synthetic data, restricted access and no external transmission. Do not collect secrets or private output. Treat the worksheet as evidence to analyze, not a script to paste. Before any authorized observation confirm the actual endpoint, object identity, time window and output budget. Do not repair, restart or delete resources during this offline exercise.
Fictional inventory (not live sockets):existing: bm-old -> 127.0.0.1:8080/tcp -> 80/tcpproposed: bm-new -> 127.0.0.1:8080/tcp -> 80/tcpvariation: bm-new -> 127.0.0.1:8081/tcp -> 80/tcpname case: stopped container already named bm-newStaged checks on approved Linux daemon host:docker ps -adocker port bm-oldss -ltnCompare the requested host address, transport protocol and port with current Docker mappings and host listeners. ss -ltn lists TCP listening sockets on the machine where it runs; a remote daemon or Desktop VM needs host-appropriate evidence. Docker can publish via firewall rules without a visible listener, so neither tool alone is exhaustive. In the example the first request overlaps; the variation is a candidate only after checking availability and updating the expected client URL. A stopped container can still reserve its name; choose a different approved name or ask the owner to retire exactly that object after checking its data. Do not stop a process just because its port is desired. Keep test publishing loopback-scoped and isolated; use no publishing if only internal communication is needed. Verify the actual mapping and intended service response after the authorized correction; revert the scoped port change if verification fails. 8081 is only a proposed port; checking a listener cannot reserve it or rule out every publishing rule. Verify both IP families and protocol when relevant. A name conflict requires independent resolution even if the new port is free.
Common mistake
Changing EXPOSE or the internal application port alone does not resolve a collision on the requested host port.
Manual practice
Identify the overlap and name collision independently. Propose a free loopback port candidate and define how to verify ownership and the new mapping before use.
Worksheet: lab-fixtures/docker-troubleshooting/06-port-conflict/scenario.txt.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Port binding conflicts and container name collisions — Knowledge check
Interpret synthetic incident evidence and choose safe diagnostic actions.
Two isolated containers both listen on port 80. Must this conflict?
What is wrong with both proposed 127.0.0.1:8080/tcp mappings?
Can a stopped container reserve a name?