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

Đang mở
#861 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, docker-compose, linux
Lĩnh vực
backend, networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
53
Fork
24
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của docker/desktop-feedback

Tất cả issue của docker/desktop-feedback

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.