tldr/pages/common/docker.md

38 lines
823 B
Markdown
Raw Normal View History

# docker
2016-01-19 22:48:21 +00:00
> Manage Docker containers and images.
> Some subcommands such as `docker run` have their own usage documentation.
> More information: <https://docs.docker.com/engine/reference/commandline/cli/>.
- List currently running docker containers:
2018-12-13 09:47:48 +00:00
`docker ps`
- List all docker containers (running and stopped):
2018-12-13 09:47:48 +00:00
`docker ps -a`
- Start a container from an image, with a custom name:
2018-12-13 09:47:48 +00:00
`docker run --name {{container_name}} {{image}}`
- Start or stop an existing container:
2018-12-13 09:47:48 +00:00
`docker {{start|stop}} {{container_name}}`
2015-12-29 04:25:31 +00:00
2018-11-13 18:12:03 +00:00
- Pull an image from a docker registry:
`docker pull {{image}}`
- Open a shell inside a running container:
2015-12-29 04:25:31 +00:00
2018-12-13 09:47:48 +00:00
`docker exec -it {{container_name}} {{sh}}`
2017-03-16 04:37:17 +00:00
- Remove a stopped container:
2017-03-16 04:37:17 +00:00
2018-12-13 09:47:48 +00:00
`docker rm {{container_name}}`
- Fetch and follow the logs of a container:
2018-12-13 09:47:48 +00:00
`docker logs -f {{container_name}}`