Last active
February 18, 2019 16:50
-
-
Save bind-disney/72d511149662411ed42b05112a09d806 to your computer and use it in GitHub Desktop.
Clear Docker logs
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
# 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