[BUG] `docker compose port` prints `:0` (exit 0) for a port the image exposes but the service does not publish
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza en internal/inspect/port.go, en Ports; luego lee internal/inspect/inspect_test.go y las pruebas existentes de manejo de puertos. Reproduce el caso del puerto expuesto pero no publicado y comprueba cómo docker compose port maneja los publicadores con PublishedPort == 0. El trabajo estará terminado cuando el puerto solicitado dé un error y el modo de lista lo omita, mientras que los puertos publicados y el comportamiento de ps sigan igual.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
"This issue was filed by an AI agent on a human's behalf. The human submitter may not have independently verified the report."
Description
docker compose port SERVICE PRIVATE_PORT is documented to "print the public port for a specific mapping". When the private port is only exposed (e.g. an image EXPOSE) and has no host binding, it prints :0 and exits 0 instead of failing. In list mode (docker compose port SERVICE) the same port shows up as 6379/tcp -> :0.
docker port on the same container prints no public port '6379' published for ... with exit code 1, and lists nothing in list mode. #10039 (fixing #10010) already turned the "port not found → :0" case into an error; the exposed-but-unpublished case still goes through, because the container listing reports exposed ports with PublicPort: 0 and internal/inspect/port.go keeps them.
Real-world impact: a script doing ADDR=$(docker compose port db 6379) for a redis/postgres service that does not publish its port gets :0 and exit 0, and fails later with a confusing connection error.
Steps To Reproduce
services:
web:
image: nginx:alpine
ports:
- "8080:80"
db:
image: redis:alpine # EXPOSE 6379, not published
$ docker compose -p portrepro up -d
$ docker compose -p portrepro port web 80 # control
0.0.0.0:8080 # rc=0
$ docker compose -p portrepro port db 6379
:0 # rc=0
$ docker compose -p portrepro port db
6379/tcp -> :0 # rc=0
$ docker port portrepro-db-1 6379
no public port '6379' published for portrepro-db-1 # rc=1
$ docker port portrepro-db-1
# (nothing), rc=0
Expected: port db 6379 fails like docker port does (with the existing "no port 6379/tcp for container ..." error), and list mode only lists published ports.
Compose Version
main @ ed25575984c8 (built locally: go build -o bin/docker-compose ./cmd)
Docker Environment
Server Version: 29.5.2 (colima VM, Ubuntu 24.04 aarch64), client on macOS arm64
Anything else?
Suggested fix: skip publishers with PublishedPort == 0 in internal/inspect/port.go (Ports). containerPublishers is shared with ps, which should keep showing 6379/tcp like docker ps, so it is left unchanged. With that change: port db 6379 → no port 6379/tcp for container portrepro-db-1: 6379/tcp, rc=1; port db → empty; port web 80 / port web unchanged. A unit test in internal/inspect/inspect_test.go (TestPortsSkipsExposedButUnpublishedPorts) fails on main and passes with the change. Happy to open the PR once this is triaged.
AI disclosure: Claude Code (Anthropic) found the issue, ran the reproduction, and drafted this report, the patch and the test.
- Lenguaje dominante
- Go
- Estrellas
- 38.9k
- Forks
- 6k
- Merge medio
- 2 d 22 h
- PR fusionados (30 d)
- 81
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docker/compose
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
docker/compose#14435 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] deploy.restart_policy without condition drops the restart policyQuizá libre de nuevo @akshat-lakhera la tomó hace 25 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
docker/compose#14383 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] up: an optional (required: false) service_healthy dependent is not started when a required dependent shares the failing waitPosiblemente ocupada @ndeloof la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
docker/compose#14507 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG] Negative replica count in scale flags (docker compose scale / --scale) is accepted without validationPosiblemente ocupada @arsalanyavari la tomó hace 8 días. Abiertokind/bug status/approved
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
[BUG] pre_stop hooks are skipped when up or scale stops a containerPosiblemente ocupada @htoyoda18 la tomó hace 11 días. Abiertokind/bug status/approved
Dificultad 4/5 3-5 días Aptitud para principiantes 53/100
Los mantenedores suelen responder en 1 día
Todos los issues de docker/compose
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
fluxcd/notification-controller#1441 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OneBusAway/maglev#2145 ·
Los mantenedores suelen responder en 2 días
-
priority/medium status/ready type/chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
discobox-ai/discobox#1357 ·
Los mantenedores suelen responder en 1 día
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itPosiblemente ocupada @fzn0x la tomó hoy. Abiertobug priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
edit_file diff rendering panics on invalid UTF-8 textPosiblemente ocupada @TDnorthgarden la tomó hoy. Abiertoarea/tui
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
docker/docker-agent#4955 ·
Los mantenedores suelen responder en 1 día