🐳 Docker Command Quick Reference

📐 工作原理与说明
按分类聚合条目:遍历条目列表,首次出现的分类记入有序数组并把计数置 1,后续同分类累加;柱状图以分类名为横轴、条目数为数据(图高 300),明细表逐行输出序号、分类名、该分类条目数与该分类前 2 条代表命令(以「 / 」连接)。分类名在英文态下按内置映射表替换为英文(Docker 命令)
Docker 常用命令速查。
  • 镜像:build、pull、push、images、rmi、tag。
  • 容器:run、ps、stop、start、restart、rm、exec、logs、inspect。
  • 常用参数:-d 后台、-p 端口映射、-v 挂载卷、--name 命名、-e 环境变量。
  • Dockerfile:FROM、RUN、COPY、WORKDIR、EXPOSE、CMD 与 ENTRYPOINT。

Browse a Docker cheat sheet in your browser — common commands, Dockerfile tips and Compose snippets.

📚 深度解析:Docker 命令速查

💡 常见使用场景

  • 日常 build/run/ps/exec 命令速查。
  • 排查容器起不来:快速查 logs、inspect 与 exec 进入容器的常用组合,不用每次翻文档。
查运行
`docker run -d -p 8080:80 nginx` 后台起容器并映射端口。

❓ 常见问题(FAQ)

如何看日志?
`docker logs <id>`。
容器一启动就退出怎么办?
先看日志——多半是主进程报错或执行完就结束(Docker 要求前台进程常驻)。若日志为空,用 inspect 看 ExitCode 与启动命令;也可用 docker run -it --entrypoint sh 覆盖入口进入容器手工排查,再逐项验证依赖与配置。

Formula & Standard References

Item Formula / Note Source / Standard
Images and containers images are read-only templates; containers add a writable layer Docker documentation
Network modes bridge, host, none and overlay are the common modes Docker documentation
Persistence volumes are managed by Docker; bind mounts map host paths Docker documentation
⚠️ 使用说明与注意事项