Docker "port is already allocated": identify the host-port owner

Scope: Docker Engine or Desktop failing to bind a published TCP or UDP host port. Use docker ps -a --filter publish=<port>, docker port for a known container, and docker compose ps/config to inspect the resolved mapping. If Docker owns no matching port, use the operating system's trusted listener tool to identify the PID and process. Remember that HOST_PORT:CONTAINER_PORT puts the host port on the left.

After identifying the owner, normally stop or replace an intentional old container, or select a conflict-free host port while keeping the right side equal to the port where the application listens. TCP and UDP bindings are separate.

Do not kill an unknown PID or run docker rm -f before checking service impact, mounts, volumes, and writable data. Publishing without a host address commonly exposes the port on every interface; bind to 127.0.0.1 when only the host should reach it.