Files
tldr/pages.zh/common/docker.md
2022-03-27 02:25:15 -03:00

38 lines
806 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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 {{容器名称}}`