| 止损 | docker update --restart=no myapp 或 docker stop |
|---|---|
| 看现场 | docker logs --tail=200;RestartCount 从 inspect 读 |
| 复现 | docker run -it --rm --entrypoint sh 镜像 手动执行启动命令 |
| 高频原因 | PID 1 秒退、配置/密钥缺失、连不上数据库、权限不足 |
| 修复 | 改配置/命令后重建,再恢复重启策略 |
排查命令
排查命令
docker inspect myapp -f 'Restarts={{.RestartCount}} Status={{.State.Status}}'
docker logs myapp --tail=200
docker run --rm -it --entrypoint sh myapp:1.2.3
# 手动执行原 CMD,观察报错『容器重启对用户不可见但请求全 5xx』常见于入口脚本第二行就退出:日志里往往只有第一行输出,留意。