Docker 调试命令
📅 2026-05-25
📁 运维手册
docker
debug
container
容器检查
# 列出运行中的容器
docker ps
# 容器日志
docker logs -f <container-name> --tail 100
# 容器进程列表
docker top <container-name>
# 容器资源统计
docker stats --no-stream
进入容器内部
# 进入容器 shell
docker exec -it <container-name> /bin/sh
# 检查容器文件系统
docker diff <container-name>
# 容器网络信息
docker inspect <container-name> | jq '.[0].NetworkSettings'
网络调试
# 检查 DNS 解析
docker exec <container-name> nslookup <hostname>
# 检查端口连通性
docker exec <container-name> nc -zv <host> <port>
# 查看容器网络
docker network ls
docker network inspect <network-name>
性能
# 容器资源使用情况
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
# 检查镜像层大小
docker history <image-name>
清理
# 删除未使用的容器/镜像/网络
docker system prune -f