Created
November 2, 2023 11:59
-
-
Save macbre/61a20c4162c34a8705d9fb93b7a9349b to your computer and use it in GitHub Desktop.
Docker utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://docs.docker.com/engine/reference/commandline/ps/#format | |
df -h / | |
for container in $(docker ps --format "{{.Names}}") | |
do | |
echo "Truncating logs for the '${container}' container ..." | |
# https://forums.docker.com/t/how-to-limit-or-rotate-docker-container-logs/112378/9 | |
truncate $(docker container inspect ${container} --format "{{ .LogPath }}") --size 0 | |
done | |
df -h / | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment