Skip to content

Instantly share code, notes, and snippets.

@stefanfoulis
Created September 16, 2014 09:05
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save stefanfoulis/604ea00fd66eea03607b to your computer and use it in GitHub Desktop.
Save stefanfoulis/604ea00fd66eea03607b to your computer and use it in GitHub Desktop.
delete docker logs
find /var/lib/docker/containers/ -type f -name "*.log" -delete
@jongio
Copy link

jongio commented Nov 14, 2017

I had to run this first

sudo -i

@RobertHeim
Copy link

RobertHeim commented Jan 26, 2023

an alternative may be activating log rotation for the docker daemon by creating/updating /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "15m",
    "max-file": "5",
  }
}

Note that you will need to restart docker (e.g. systemctl restart docker) and the config only affects containers created after modifying the daemon configuration (e.g. recreate the container of a specific service in docker-compose: docker-compose up --force-recreate --no-deps -d <service-name>).

For more information see: https://docs.docker.com/config/containers/logging/json-file/

@stefanfoulis
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment