mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-22 14:02:08 +02:00

The start and stop examples are pretty much identical, so it doesn't make sense to use up the space of two examples in the limited length of a tldr page (especially for such a complex command as docker). In the slot left by combining the two entries, a new one is added mentioning how to launch a container from an image. Placing this example before the start/stop commands (and naming the parameter "container_name" consistently trhoughout the page) also makes the sequence more logical, by first explaining how containers are instantiated, and only then mentioning how they are managed.
792 B
792 B
docker
Manage Docker containers and images.
- List currently running docker containers:
docker container ls
- List all docker containers (running and stopped):
docker container ls -a
- Start a container from an image, with a custom name:
docker container run --name={{container_name}} {{image}}
- Start or stop an existing container:
docker container {{start|stop}} {{container_name}}
- Start a container from an image and get a shell inside of it:
docker container run -it {{image}} bash
- Run a command inside of an already running container:
docker container exec {{container_name}} {{command}}
- Remove a stopped container:
docker container rm {{container_name}}
- Fetch and follow the logs of a container:
docker container logs -f {{container_name}}