Skip to content

Instantly share code, notes, and snippets.

@bind-disney
Last active February 18, 2019 16:50
Show Gist options
  • Save bind-disney/72d511149662411ed42b05112a09d806 to your computer and use it in GitHub Desktop.
Save bind-disney/72d511149662411ed42b05112a09d806 to your computer and use it in GitHub Desktop.
Clear Docker logs
# Mac
#
# Usage: clear_docker_logs <CONTAINER_NAME> | <CONTAINER_ID>
clear_docker_logs() {
docker_log_file=$(docker inspect --format='{{.LogPath}}' $1)
clear_command="truncate -S 0 $docker_log_file"
screen -d -m -S dockerlogdelete ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
screen -S dockerlogdelete -p 0 -X stuff $"$clear_command"
screen -S dockerlogdelete -p 0 -X stuff $'\n'
screen -S dockerlogdelete -X quit
}
# Linux
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment