tldr/pages/common/docker.md

36 lines
792 B
Markdown
Raw Normal View History

# docker
2016-01-19 22:48:21 +00:00
> 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}}`
2015-12-29 04:25:31 +00:00
- Start a container from an image and get a shell inside of it:
2015-12-29 04:25:31 +00:00
`docker container run -it {{image}} bash`
2015-12-29 04:25:31 +00:00
- Run a command inside of an already running container:
2015-12-29 04:25:31 +00:00
`docker container exec {{container_name}} {{command}}`
2017-03-16 04:37:17 +00:00
- Remove a stopped container:
2017-03-16 04:37:17 +00:00
`docker container rm {{container_name}}`
- Fetch and follow the logs of a container:
`docker container logs -f {{container_name}}`