2015-12-27 18:11:20 +00:00
|
|
|
# docker
|
|
|
|
|
2016-01-19 22:48:21 +00:00
|
|
|
> Manage Docker containers and images.
|
2021-09-13 09:21:21 +01:00
|
|
|
> Some subcommands such as `docker run` have their own usage documentation.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://docs.docker.com/engine/reference/commandline/cli/>.
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2017-04-27 23:55:32 +01:00
|
|
|
- List currently running docker containers:
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2018-12-13 09:47:48 +00:00
|
|
|
`docker ps`
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- List all docker containers (running and stopped):
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2018-12-13 09:47:48 +00:00
|
|
|
`docker ps -a`
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2018-10-01 17:20:57 +01:00
|
|
|
- Start a container from an image, with a custom name:
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2018-12-13 09:47:48 +00:00
|
|
|
`docker run --name {{container_name}} {{image}}`
|
2015-12-27 18:11:20 +00:00
|
|
|
|
2018-10-01 17:20:57 +01:00
|
|
|
- Start or stop an existing container:
|
2015-12-27 18:11:20 +00:00
|
|
|
|
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}}`
|
|
|
|
|
2021-08-15 18:59:09 +01:00
|
|
|
- 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
|
|
|
|
2017-09-28 10:25:00 +01: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}}`
|
2017-11-27 18:14:42 +00:00
|
|
|
|
|
|
|
- Fetch and follow the logs of a container:
|
|
|
|
|
2018-12-13 09:47:48 +00:00
|
|
|
`docker logs -f {{container_name}}`
|