2022-03-19 14:19:55 +01:00
|
|
|
---
|
2024-12-27 12:28:33 +01:00
|
|
|
title: Goodies to know for Docker & Docker-Compose
|
2023-01-15 18:05:39 +01:00
|
|
|
description: This is my list of use full Docker commands.
|
2024-12-27 12:28:33 +01:00
|
|
|
date: 2024-11-06T21:05:38.188Z
|
|
|
|
lastmod: 2024-12-27T11:26:27.203Z
|
2022-03-19 14:19:55 +01:00
|
|
|
image: /images/blog/Image-Docker-Command-Cheat-Sheet.png
|
|
|
|
tags:
|
2023-01-15 18:06:12 +01:00
|
|
|
- Cheat-Sheet
|
|
|
|
- Command-Line
|
2024-02-13 22:37:17 +01:00
|
|
|
- Docker
|
2023-01-15 18:06:12 +01:00
|
|
|
- Linux
|
2024-02-13 22:37:17 +01:00
|
|
|
slug: docker-compose-cheat-sheet
|
2024-09-11 23:05:27 +02:00
|
|
|
draft: true
|
2022-03-19 14:19:55 +01:00
|
|
|
---
|
|
|
|
|
2024-12-27 12:28:33 +01:00
|
|
|
This is the colleton of useful knowledge this kitty has gathered for Docker and Docker-Compose over a long time.
|
2022-03-19 14:19:55 +01:00
|
|
|
|
2024-12-27 12:30:01 +01:00
|
|
|
{{< toc >}}
|
2023-01-15 18:21:04 +01:00
|
|
|
|
|
|
|
## 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](https://docs.docker.com/engine/reference/commandline/network_prune))
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker network prune
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Containers, Volumes, Images
|
|
|
|
|
|
|
|
And to purge the docker system ([Docker Docs](https://docs.docker.com/engine/reference/commandline/system_prune))
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker system prune
|
|
|
|
```
|
|
|
|
|
|
|
|
### The old way (Docker < 1.13)
|
|
|
|
|
|
|
|
#### Delete Volumes
|
|
|
|
|
|
|
|
{{< alert theme="info" >}} // see: https://github.com/chadoe/docker-cleanup-volumes {{< /alert >}}
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker volume rm $(docker volume ls -qf dangling=true)
|
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker volume ls -qf dangling=true | xargs -r docker volume rm
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Delete Networks
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker network ls
|
|
|
|
```
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker network ls | grep "bridge"
|
|
|
|
```
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')
|
|
|
|
```
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
```Shell
|
|
|
|
docker network ls | awk '$3 == "bridge" && $2 != "bridge" { print $1 }'
|
2024-02-13 22:37:17 +01:00
|
|
|
```
|
2024-12-27 12:31:08 +01:00
|
|
|
|
|
|
|
## Conclusion
|
|
|
|
|
|
|
|
First of thanks for reading this.
|
|
|
|
|
|
|
|
I hope this has been helpful and if you have any questions, suggestions or something i may have missed, please let me know.
|