Keep the published host port distinct from the container port
Example input
docker run --name web -p 8080:80 nginx:stableExpected result
ports:
- "8080:80"The fragment preserves host port 8080 forwarding to container port 80. It is an excerpt from the generated service definition, not a whole Compose file. Review any warnings about unsupported flags, then check the complete YAML with your Compose tooling. The image tag in the sample is illustrative and is not a recommendation to deploy an unreviewed mutable tag.