#14229·compose

"docker compose run" should warn when "ports" configuration is available but "--service-ports" is not supplied

Author: dnmvisserCreated Sep 16, 2026Updated Sep 16, 2026
Labelskind/featurestatus/0-triage

Description

When you have a docker-compose.yml that contains ports entries, for example:

yaml
---
services:
  web:
    image: crccheck/hello-world
    ports:
      - 8000:8000

then this works as expected with "compose up":

bash
# docker compose up web
Attaching to web-1
web-1  | httpd started

I can then reach the service from the host, and also from another system.

When doing "run", things seems similarly OK:

bash
# docker compose run web
Container tmp-web-run-25ac0b9f7167 Creating
Container tmp-web-run-25ac0b9f7167 Created
httpd started

But now I cannot reach the container, not from the host, not from another system.

Turns out that I should have RTFM, because in there it says:

If you do want the service’s ports to be created and mapped to the host, specify the --service-ports

This came unexpected and cost me a few hours. I think it would be a Good Idea™ to have docker compose run print something like this:

WARNING the compose file contains explicit ports statements, but those won't be effective unless you supply the --service-ports argument

Such a message would prevent other people from getting stuck, while being harmless and not affect any functionality.