1. [root@lzone_zkong_cluster_01 scripts]# cat docker-log.sh
    2. #!/bin/bash
    3. # Clean up container log - Jiu Wen (Version 1.1)
    4. # Debian/Ubuntu Linux systems. (May 10, 2019)
    5. # (GNU/General Public License version 2.0)
    6. # For Centos 7 and up, Linux lzone_zkong_cluster_01 3.10.0-862.el7.x86_64.
    7. # ...And away we go!
    8. # 清理docker日志和镜像
    9. #set -xu
    10. Container_PATH="/var/lib/docker/containers/"
    11. Container() {
    12. echo -e "\033[44;37m The log size of the native docker container is as follows \033[0m"
    13. for i in `find $Container_PATH -type f -name *-json.log*`
    14. do
    15. ls -sh $i
    16. done
    17. echo -e "\033[44;37m Start cleaning up docker container log \033[0m"
    18. for i in `find $Container_PATH -type f -name *-json.log*`
    19. do
    20. cat /dev/null > $i
    21. done
    22. echo -e "\033[44;37m Cleaning up dangling mirrors \033[0m"
    23. docker rmi `docker images --filter dangling=true|awk '{print $3}'` 2> /dev/null
    24. echo -e "\033[44;37m Clean up \033[0m"
    25. for i in `find $Container_PATH -name *-json.log*`
    26. do
    27. ls -sh $i
    28. done
    29. }
    30. Container