mirror of
https://github.com/Aroy-Art/Aroy-Art-Site.git
synced 2024-12-27 13:04:23 +01:00
3.2 KiB
3.2 KiB
title | description | date | lastmod | image | tags | slug | draft | ||||
---|---|---|---|---|---|---|---|---|---|---|---|
Docker & Compose Cheat Sheet | This is my list of use full Docker commands. | 2020-12-02T00:00:00.000Z | 2024-09-11T21:04:52.148Z | /images/blog/Image-Docker-Command-Cheat-Sheet.png |
|
docker-compose-cheat-sheet | true |
A list of docker commands
List images
docker images [OPTIONS] [REPOSITORY[:TAG]]
Options
Name, shorthand | Default | Description |
---|---|---|
--all, -a |
Show all images (default hides intermediate images) | |
--digests |
Show digests | |
--filter, -f |
Filter output based on conditions provided | |
--format |
Pretty-print images using a Go template | |
--no-trunc |
Don’t truncate output | |
--quiet, -q |
Only show numeric IDs |
Remove one or more containers
docker rm [OPTIONS] CONTAINER [CONTAINER...]
Options
Name, shorthand | Default | Description |
---|---|---|
--force, -f |
Force the removal of a running container (uses SIGKILL) | |
--link, -l |
Remove the specified link | |
--volumes, -v |
Remove anonymous volumes associated with the container |
Stop one or more running containers
docker stop [OPTIONS] CONTAINER [CONTAINER...]
Options
Name, shorthand | Default | Description |
---|---|---|
--time, -t |
10 | Seconds to wait for stop before killing it. |
How to cleanup (unused) resources
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
If you use a Docker version newer than > 1.13 you can use Dockers builtin cleanup tool purge
.
The new way (Docker > 1.13)
Network
To purge the networks (Docker Docs)
docker network prune
Containers, Volumes, Images
And to purge the docker system (Docker Docs)
docker system prune
The old way (Docker < 1.13)
Delete Volumes
{{< alert theme="info" >}} // see: https://github.com/chadoe/docker-cleanup-volumes {{< /alert >}}
docker volume rm $(docker volume ls -qf dangling=true)
or
docker volume ls -qf dangling=true | xargs -r docker volume rm
Delete Networks
docker network ls
docker network ls | grep "bridge"
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
or
docker network ls | awk '$3 == "bridge" && $2 != "bridge" { print $1 }'