`nerdctl kill -s <signal>` removes the network of a container that continues to run
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/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ệ
- go
- Lĩnh vực
- cli, networking
Hướng nghiên cứu
Start with pkg/cmd/container/kill.go and trace how Kill, cleanupNetwork, and killContainer handle signal and task status; compare the stop signal behavior with SIGKILL. Check the related issue #5323 for context, then run the container kill tests and reproduce the SIGHUP case with the steps in this report. Done means non-stopping signals preserve networking and health checks, while failed kills on stopped containers leave the network allocation intact.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
nerdctl kill removes the network of the container for every signal, not only for signals that stop the container. When the signal does not stop the container (for example SIGHUP to reload nginx), the container continues to run without its network setup:
- Published ports stop working.
- The IP address goes back to the IPAM pool. A new container can then get the same IP address while the first container still uses it.
Steps to reproduce the issue
sudo nerdctl run -d --name lab-hup -p 127.0.0.1:18080:80 --ip 10.4.0.240 nginx:alpine
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18080 # 200
sudo nerdctl kill -s SIGHUP lab-hup
sudo nerdctl inspect lab-hup --format '{{.State.Status}}' # running
curl -s -o /dev/null -w '%{http_code}\n' --max-time 3 http://127.0.0.1:18080 # 000
sudo ls /var/lib/cni/networks/bridge/10.4.0.240 # No such file or directory
sudo nerdctl run -d --name lab-dup --ip 10.4.0.240 alpine sleep infinity # succeeds
sudo nerdctl exec lab-hup ip -4 -o addr show eth0 # 10.4.0.240/24
sudo nerdctl exec lab-dup ip -4 -o addr show eth0 # 10.4.0.240/24
Describe the results you received and expected
Expected
A signal that does not stop the container does not change its network. The published port continues to work. The IP address stays allocated, so nerdctl run --ip 10.4.0.240 fails for a second container.
Received
After kill -s SIGHUP:
| Check | Result |
|---|---|
| Container status | running |
| HTTP on the published port | no response (000) |
| CNI lease file for 10.4.0.240 | removed |
Second container with --ip 10.4.0.240 |
starts, and both containers have 10.4.0.240 |
Cause
In pkg/cmd/container/kill.go, Kill calls cleanupNetwork before killContainer, for all signals. cleanupNetwork calls cni.Remove, which removes the port forwards and releases the IP address. The function does not check the signal or the task status.
The same order has a second effect. When the container is not running, cleanupNetwork runs first, and then killContainer fails with container is not running. The command fails, but the IP address is already released.
healthcheck.RemoveTransientHealthCheckFiles in killContainer also runs for every signal. So after kill -s SIGHUP, the container may continue to run without its health check. I did not test this part.
Possible fix
- Check the task status before
cleanupNetwork. If the container is not running, return the error and do not change the network. - Call
cleanupNetworkonly when the signal isSIGKILLor the stop signal of the container (SIGTERMby default).
With step 2, kill -s SIGTERM on a container that ignores SIGTERM still removes the network. That is the current behavior, and nerdctl stop has the same risk.
What version of nerdctl are you using?
main at dc841ac6. The result is the same with the fix for #5323 applied.
Host information
- containerd v2.4.1, runc 1.5.2, rootful
- Ubuntu 24.04, kernel 6.8, aarch64
- Network: default
bridge
Related: #5323. In that issue, nerdctl also releases the network at the wrong time. The fix for #5323 does not change this behavior.
- Ngôn ngữ chính
- Go
- Star
- 10.5k
- Fork
- 839
- Merge trung bình
- 3 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của containerd/nerdctl
-
Test and examples: update wordpress images (to silence potential false security alerts)Có thể làm lại được @ayushpratap27 đã nhận 16 ngày trước và không có pull request nào đang mở. Đang mởarea/ci documentation priority/low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
containerd/nerdctl#5283 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`nerdctl kill` shouldn't set `containerd.io/restart.explicitly-stopped` label for non-stop signalsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
containerd/nerdctl#5171 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`nerdctl stop` on an exited container frees its IP but keeps its /etc/hosts entry, so a later container can lose its nameCó thể đã có người làm @papidb đã nhận 3 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
containerd/nerdctl#5323 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
fluentd log driver: default retry wait is passed in nanosecondsCó thể đã có người làm @ogulcanaydogan đã nhận 5 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
containerd/nerdctl#5320 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
compose: only the last volume's create_host_path directories are createdCó thể đã có người làm @ogulcanaydogan đã nhận 7 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
containerd/nerdctl#5317 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của containerd/nerdctl
Issue tương tự
-
book-layout.spec fails when the similar-books rail holds other projects' booksCó thể đã có người làm @praetorianer777 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
praetorianer777/GoTome#373 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
-
/shutdown/ready can fail to return an HTTP response when readiness takes longer than the server write timeoutCó thể đã có người làm @floriankoch đã nhận hôm nay. Đang mởtriage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
envoyproxy/gateway#10562 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Adding an LDAP group reports every search failure as "LDAP Group DN is not found"Có thể đã có người làm @Daksha1611 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày