tldr/pages.zh/common/docker.md

38 lines
806 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# docker
> 管理 Docker 容器和镜像。
> 此命令也有关于其子命令的文件,例如:`docker run`.
> 更多信息:<https://docs.docker.com/engine/reference/commandline/cli/>.
- 列出目前正在运行的 docker 容器:
`docker ps`
- 列出所有 docker 容器(包括停止的容器):
`docker ps -a`
- 透过镜像启动容器,并为容器命名:
`docker run --name {{容器名称}} {{镜像}}`
- 启动或停止现有容器:
`docker {{start|stop}} {{容器名称}}`
- 从 docker registry 中拉取镜像:
`docker pull {{镜像}}`
- 从正在运行的容器内打开一个 shell
`docker exec -it {{容器名称}} {{sh}}`
- 删除一个停止的容器:
`docker rm {{容器名称}}`
- 获取并查看容器的日志:
`docker logs -f {{容器名称}}`