Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding log rotation to exsisting container without recreateing

Tags:

docker

Docker logs are way too big with default configuration, and it's eating up my server space.

I know I can configure /etc/docker/daemon.json and add something like this:

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

and restart Docker service. But it only works for NEW containers.

Is there a way to update log rotation configuration of exsisting container without recreating it?

like image 887
NoobTW Avatar asked Oct 31 '25 20:10

NoobTW


1 Answers

You can't change most container settings without recreating it (the list of available settings is here). I suggest you rather recreate containers with the new log policy because that is simpler and cleaner than the alternative, which is to configure logrotate for these files: /var/lib/docker/containers/*/*.log.

like image 180
anemyte Avatar answered Nov 03 '25 13:11

anemyte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!