[WSL 2] After engine recovery, published ports are restored with the containers' old IPs and forward to the wrong container

Abierto
#861 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, docker-compose, linux

Línea de trabajo

Start by tracing wsl-bootstrap's recovery path: where it restores GET /forwards/list and where restarted containers trigger exposer.Add. Compare those paths with the supplied backend log and reproduce the sequence using the listed Docker commands. Done when recovery restores forwards to each restarted container's current IP, or reconciles the saved list so the published port returns HTTP 200 without a manual restart.

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

Descripción

kind/bug platform/windows
Bug report

This replaces #853, which I filed without the issue form, so it never got its triage labels. The content is the same.

When the WSL 2 engine dies and Docker Desktop recovers it by itself, containers with a restart policy come back, often with different IPs on their user-defined networks. Docker Desktop does not register their published ports again. wsl-bootstrap restores the saved forward list (GET /forwards/list) with the IPs from before the failure, and no exposer.Add follows for the restarted containers. A published port then forwards to whatever now holds the old IP: another container of the same project, or nothing.

Symptom: curl http://localhost:<port> gives Empty reply from server, while the service answers inside its container. docker ps shows the container Up with the port published. The only trace is in com.docker.backend.exe.log:

unable to connect on docker-containers/<id> tcp forward from 0.0.0.0:5053 to 172.24.0.3:8000: dial tcp 172.24.0.3:8000: connect: connection refused

It lasts until each affected container is restarted by hand (docker restart), which registers the port again with the current IP.

Containers alone on their network usually get the same IP back, so the failure looks random: here only multi-container compose projects broke.

Reproduce (confirmed, about 30 seconds)

docker network create fwdrepro
docker run -d --name fwd-a --network fwdrepro alpine:3.20 sleep infinity                            # takes .2, no restart policy
docker run -d --name fwd-pub --network fwdrepro --restart unless-stopped -p 5098:80 nginx:1.27-alpine  # takes .3
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:5098/      # 200
wsl --terminate docker-desktop                                      # engine dies; Docker Desktop recovers it
# after recovery: fwd-a stays stopped, fwd-pub restarts and gets .2
docker inspect -f '{{.NetworkSettings.Networks.fwdrepro.IPAddress}}' fwd-pub   # 192.168.48.2
curl http://127.0.0.1:5098/                                         # Empty reply from server (000)
docker exec fwd-pub wget -qO- http://localhost/                     # nginx answers inside
docker restart fwd-pub && curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:5098/   # 200 again

Backend log of that run (UTC):

11:41:35 exposer.Add(<fwd-pub>, /fwd-pub, [TCP 0.0.0.0:5098 -> 192.168.48.3:80])
11:41:38 [wsl-bootstrap.vpnkitcontrol] adding docker-containers/<fwd-pub> tcp forward from 0.0.0.0:5098 to 192.168.48.3:80
11:41:44 (wsl --terminate docker-desktop)
         [wsl-bootstrap.vpnkitcontrol] adding docker-containers/<fwd-pub> tcp forward from 0.0.0.0:5098 to 192.168.48.3:80   (replayed after recovery)
11:42:09 fwd-pub running again, IP 192.168.48.2; no exposer.Add for it
11:42:42 (docker restart fwd-pub) exposer.Add(<fwd-pub>, /fwd-pub, [TCP 0.0.0.0:5098 -> 192.168.48.2:80])  -> works

How we hit it in the wild

On 2026-11-14 at 03:59 to 04:01 UTC, Windows Update installed WSL 3.0.5.0 (MsiInstaller events 1040 and 1033). That killed the engine (engine linux/wsl shutdown requested (cancel cause: ... Wsl/CallMsi/Install/ERROR_NOT_FOUND)). Docker Desktop recovered (attempting recovery from engine failure ... selected recovery action: Restart), wsl-bootstrap restored all 18 saved forwards from GET /forwards/list with their old IPs, and zero exposer.Add calls followed. Two compose projects broke for about 7 hours, until someone noticed:

Project A (user-test-companion_default): the app moved from 172.24.0.3 to .2 and the db took .3, so 5053 -> 172.24.0.3:8000 pointed at the db.

Project B (jobb_default, five containers): all three published ports pointed at other containers of the project. 8000 pointed at the frontend, 5173 at another service, and 5434 at the API.

Expected

After an engine recovery, restarted containers register their published ports from their current state, as on a normal start. Or the restored forward list is reconciled with the containers' current IPs.

Platform

Windows

Version information
- Reproduced on Docker Desktop 4.99.0 (Engine 29.9.3), the latest at the time: same steps, same result (fwd-pub .3 to .2, port 5098 gives an empty reply; `jobb` and `user-test-companion` stacks broke again too).
- First seen and reproduced on Docker Desktop 4.92.0 (build 240144), Engine 29.8.0 (the log excerpt above is from that run).
- A normal Docker Desktop restart (the 4.99.0 update itself) registers every port correctly; only the engine-recovery path restores stale forwards.
- WSL 3.0.5.0, kernel 6.18.58.1-1
- Windows 11 Home 10.0.26200
- Backend: WSL 2
Diagnostics ID

No response

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 Backend & API Design

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.