Skip to content

Instantly share code, notes, and snippets.

@piavgh
Created February 1, 2021 07:35
Show Gist options
  • Save piavgh/6b82fe4c79bf1778d8abfc941d1f1e92 to your computer and use it in GitHub Desktop.
Save piavgh/6b82fe4c79bf1778d8abfc941d1f1e92 to your computer and use it in GitHub Desktop.
Clear Docker logs
#!/bin/bash -e
if [[ -z $1 ]]; then
echo "No container specified"
exit 1
fi
if [[ "$(docker ps -aq -f name=^/${1}$ 2> /dev/null)" == "" ]]; then
echo "Container \"$1\" does not exist, exiting."
exit 1
fi
log=$(docker inspect -f '{{.LogPath}}' $1 2> /dev/null)
sudo truncate -s 0 $log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment