2015-12-27 23:41:20 +05:30
|
|
|
# docker
|
|
|
|
|
2016-01-19 14:48:21 -08:00
|
|
|
> Manage Docker containers and images.
|
2024-10-04 21:14:41 +02:00
|
|
|
> Some subcommands such as `run` have their own usage documentation.
|
2024-09-29 02:45:40 -07:00
|
|
|
> More information: <https://docs.docker.com/reference/cli/docker/>.
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2024-03-14 02:01:06 -03:00
|
|
|
- List all Docker containers (running and stopped):
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2025-03-17 12:09:59 +02:00
|
|
|
`docker ps {{[-a|--all]}}`
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2018-10-01 17:20:57 +01:00
|
|
|
- Start a container from an image, with a custom name:
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2018-12-13 04:47:48 -05:00
|
|
|
`docker run --name {{container_name}} {{image}}`
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2018-10-01 17:20:57 +01:00
|
|
|
- Start or stop an existing container:
|
2015-12-27 23:41:20 +05:30
|
|
|
|
2018-12-13 04:47:48 -05:00
|
|
|
`docker {{start|stop}} {{container_name}}`
|
2015-12-28 23:25:31 -05:00
|
|
|
|
2024-03-14 02:01:06 -03:00
|
|
|
- Pull an image from a Docker registry:
|
2018-11-14 02:12:03 +08:00
|
|
|
|
|
|
|
`docker pull {{image}}`
|
|
|
|
|
2021-12-30 13:37:01 +01:00
|
|
|
- Display the list of already downloaded images:
|
|
|
|
|
|
|
|
`docker images`
|
|
|
|
|
2025-03-17 12:09:59 +02:00
|
|
|
- Open an interactive tty with Bourne shell (`sh`) inside a running container:
|
2015-12-28 23:25:31 -05:00
|
|
|
|
2025-03-17 12:09:59 +02:00
|
|
|
`docker exec {{[-it|--interactive --tty]}} {{container_name}} {{sh}}`
|
2017-03-16 00:37:17 -04:00
|
|
|
|
2025-02-08 16:01:33 +02:00
|
|
|
- Remove stopped containers:
|
2017-03-16 00:37:17 -04:00
|
|
|
|
2025-02-08 16:01:33 +02:00
|
|
|
`docker rm {{container1 container2 ...}}`
|
2017-11-27 12:14:42 -06:00
|
|
|
|
|
|
|
- Fetch and follow the logs of a container:
|
|
|
|
|
2025-03-17 12:09:59 +02:00
|
|
|
`docker logs {{[-f|--follow]}} {{container_name}}`
|