Containers’ logs are stored in json under the /var/lib/containers/ folder.

Easiest way to retrieve them is to use the docker inspect command on each running container in order to retrieve the exact path.

Hence the following script will do the job (to be stored in a docker-clean-logs.sh file) :

#!/bin/zsh
docker ps -a -q | while read DOCKER_ID ; do
  LOG_FILE=$(docker inspect --format='{{.LogPath}}' $DOCKER_ID)
  CONTAINER_NAME=$(docker inspect --format='{{.Name}}' $DOCKER_ID)
  if [[ ! -z "$LOG_FILE" && -f "$LOG_FILE" ]] ; then
    printf "%35s\t%s\t%s\n" $CONTAINER_NAME $(du -ksh "$LOG_FILE")
    cat /dev/null > "$LOG_FILE"
  fi
done

Example of a possible output :

/tensin-app-xiaomi-miplant	92M	/var/lib/docker/containers/7a7a630a2e11566cbe6fc0b3fcde04295aa87055de822a41e6bcbd1fa0713538/7a7a630a2e11566cbe6fc0b3fcde04295aa87055de822a41e6bcbd1fa0713538-json.log