docker - docker 容器在运行基准测试后丢失端口转发
问题描述
docker 容器在运行基准测试后丢失端口转发,可以 100% 重现。
环境:Ubuntu 20.04.1 LTS,docker 19.03.11,wrk 4.1.0。
docker run -d -p 8080:80 --name my-nginx nginx:1.18
netstat -ntulp | grep 8080
# tcp6 0 0 :::8080 :::* LISTEN 6237/docker-proxy
# at the beginning of this benchmark, my-nginx can still be accessed through localhost:8080
wrk -t12 -c1000 -d30s http://localhost:8080
netstat -ntulp | grep 8080
# empty
wrk -t12 -c1000 -d30s http://localhost:8080
# unable to connect to localhost:8080 Connection refused
# get my-nginx's ip
docker inspect my-nginx
# my-nginx can be accessed through container_ip:80
wrk -t12 -c1000 -d30s http://172.17.0.2:80
这是 docker 的错误还是预期行为?
更新:这似乎是一个长期存在的问题https://github.com/moby/moby/issues/8817
解决方案
推荐阅读
- android - 拍照时未调用 ImageReader.OnImageAvailableListener()
- python - 如何修复我的硒代码超时异常错误?
- amazon-web-services - 为什么 Amazon Forecast 无法训练预测器?
- automata - (T/F) 给定一个 NFA 具有 null/epsilon 转换,可以创建另一个接受相同语言但没有 null 转换的 NFA
- php - PDO 变更查询
- php - 如何在使用 php 之前更改 url
- amazon-web-services - 问题:使用 Kops 在 AWS 上创建 Kubernetes 集群
- javascript - 数据流向
- c# - 使用 Roslyn 构建“无项目”(无 `.csproj`)网站项目 (WSP) - MSBuildWorkspace 不支持
- if-statement - 导致解析错误的正确 IF 语句问题