Skip to content

Instantly share code, notes, and snippets.

@macbre
Created November 2, 2023 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macbre/61a20c4162c34a8705d9fb93b7a9349b to your computer and use it in GitHub Desktop.
Save macbre/61a20c4162c34a8705d9fb93b7a9349b to your computer and use it in GitHub Desktop.
Docker utils
#!/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