Repeated container port on non-loopback host IPs fails to start: failed to bind host port 127.0.0.1 (address already in use)

Abierto
#845 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker
Área
networking

Línea de trabajo

Start with the Docker Desktop network forwarder, since the report points to an internal loopback port bind failure during container networking; the issue does not name a source file or test. Reproduce with the docker run command and compare the listed host IP and repeated container port cases. Done means both mappings start and forward successfully on non-loopback host IPs.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Platform: macOS (arm64, macOS 27.0.1)

Bug description

Publishing the same container port more than once fails at container creation
when the host IP is a non-loopback address — including the case where both
publications use the same host IP. The daemon reports a 127.0.0.1:
port that was never requested, and which nothing is listening on.

Impact: a host with a primary and a secondary LAN address (e.g. en0 with
192.168.86.93 and an alias 192.168.86.15) cannot forward the same service port on
each address into the engine. Two services exposed as 192.168.86.93:8883 and
192.168.86.15:8883 — the normal way to give each its own identity — cannot both
be published. On Linux each binding gets its own proxy/DNAT rule and this works;
here container creation aborts.

Reproduction steps

Minimal, no application involved:

docker run -d --name t --entrypoint sleep \
  -p 192.168.86.93:18883:8883 \
  -p 192.168.86.93:18884:8883 \
  python:3-alpine 60

Result:

docker: Error response from daemon: failed to set up container networking:
driver failed programming external connectivity on endpoint t (…): failed to
bind host port 127.0.0.1:55040/tcp: address already in use

The port in that message changes on every attempt (55009, 55019, 55040, 55071
observed). Neither 18883 nor 18884 is in use before the run, and nothing holds
the reported 127.0.0.1 port.

Same result with two different LAN addresses, with the same host port on both,
and via compose:

services:
  t:
    image: python:3-alpine
    entrypoint: sleep
    command: "60"
    ports:
      - "192.168.86.15:18883:8883"
      - "192.168.86.93:18883:8883"

Matrix

All rows: python:3-alpine, 45–60s sleep, default bridge, same engine. Only the
last three rows fail.

Publications Container starts
18883:8883 + 18884:8884 (wildcard, distinct container ports) yes
18883:8883 + 18884:8883 (wildcard, same container port) yes
127.0.0.1:18883:8883 + 127.0.0.1:18884:8883 (loopback twice) yes
192.168.86.93:18883:8883 + 127.0.0.1:18884:8883 (LAN + loopback) yes
192.168.86.93:18883:8883 + 192.168.86.93:18884:8884 (same LAN IP, distinct container ports) yes
192.168.86.93:18883:8883 + 192.168.86.93:18884:8883 (same LAN IP, same container port) no
192.168.86.15:18883:8883 + 192.168.86.93:18884:8883 (two LAN IPs, same container port) no
192.168.86.15:18883:8883 + 192.168.86.93:18883:8883 (two LAN IPs, same host and container port) no

The trigger is a repeated container port combined with a non-loopback host IP, on
the same address or different ones. Different container ports on the same host IP
are fine, so it is not "two explicit bindings" in general.

This is not port exhaustion on the host: the macOS ephemeral range is the default
49152–65535, the machine has 33 listening TCP sockets, and com.docker.backend
holds ~247 TCP sockets at rest.

Expected behavior

Both mappings are active — each host address forwards to the container port, as
they do on a Linux engine.

Actual behavior

docker run returns an error and the container is not created. The message names
an internal loopback port and an EADDRINUSE on it, which points at the port
forwarder rather than the requested bindings.

Possibly related

#817 reports that on macOS a binding to a specific (loopback alias) IP silently
becomes 0.0.0.0, where it previously worked — different symptom, but if both are
regressions they may sit in the same part of the forwarder.

Diagnostics

I can generate a diagnostics ID from the app and attach it, and retest after
resetting Docker Desktop's network settings or on a clean install, if the
reproduction does not trigger in your environment.

Version information

Client:
 Version:           29.9.3
 API version:       1.56
 Go version:        go1.26.10
 Git commit:        5457199
 Built:             Tue Nov  3 21:41:57 2026
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.99.0 (245822)
 Engine:
  Version:          29.9.3
  API version:      1.56 (minimum version 1.40)
  Go version:       go1.26.10
  Git commit:       70efc0e
  Built:            Tue Nov  3 21:41:25 2026
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v2.4.2
 runc:
  Version:          1.5.2

macOS 27.0.1, Apple silicon, default bridge network, default daemon config.

Lenguaje dominante
Sin datos de lenguaje
Estrellas
53
Forks
24
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de docker/desktop-feedback

Todos los issues de docker/desktop-feedback

Issues similares

Más issues de Networking

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.