Created
July 13, 2021 05:21
-
-
Save devopsy-ir/bf5ab1340d8aad7c891712d2683d1684 to your computer and use it in GitHub Desktop.
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 | |
# Color | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
NC='\033[0m' # No Color | |
function red { | |
printf "${RED}$@${NC}\n" | |
} | |
function green { | |
printf "${GREEN}$@${NC}\n" | |
} | |
function yellow { | |
printf "${YELLOW}$@${NC}\n" | |
} | |
if [ -z "$1" ] | |
then | |
ids=$(docker ps -a --format='{{.ID}}') | |
for id in $ids | |
do | |
#echo $(docker ps -a --format='{{.ID}} ### {{.Names}} ### {{.Image}}' | fgrep $id) | |
echo -ne "$(docker ps -a --format='{{.ID}}#{{.Names}}' | fgrep $id | cut -d '#' -f2) ... " | |
truncate -s 0 $(docker inspect --format='{{.LogPath}}' $id) | |
#ls -llh $(docker inspect --format='{{.LogPath}}' $id) | |
echo -ne "$(green done)\n" | |
done | |
else | |
echo -ne "$(docker inspect --format='{{.Name}}' $1) ... " | |
truncate -s 0 $(docker inspect --format='{{.LogPath}}' $1) | |
echo -ne "$(green done)\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment