Is there any way the new configuration in daemon.json
to apply to all the containers after the daemon restarts?
Docker seems to not apply log configuration changes in daemon.json
to already running containers, even if the daemon is restarted:
daemon.json
like ... "max-file": "3" ...
docker inspect c1
shows the configurationdaemon.json
to ... "max-file": "5" ...
service docker restart
docker inspect c1
shows the old configurationdocker inspect c2
the new config applies to this oneI wouldn't expect this behaviour.
Not what you wanted to hear, but...
That behavior is to be expected. Containers are static from the point of creation in their configuration.
To underline this statement, here is an example with a storage driver. If you choose another storage driver your current containers won't work anymore. You can find this particular info here:
https://docs.docker.com/v17.09/engine/userguide/storagedriver/selectadriver/#shared-storage-systems-and-the-storage-driver
Important: When you change the storage driver, any existing images and containers become inaccessible. This is because their layers cannot be used by the new storage driver. If you revert your changes, you will be able to access the old images and containers again, but any that you pulled or created using the new driver will then be inaccessible.
To role out the changes that you have done in your deamon you need to recreate all containers on the system.
Save your data
Do you have the data stored in named volumes or hostpath volumes? If so you should be fine, otherwise you can copy any data that you need out of the containers with
docker cp container:/path/to/files /target/folder/on/host
https://docs.docker.com/engine/reference/commandline/cp/
if you use an orchestrator you could e.g. drain the node, which terminates all containers on the host and after successful draining add the node back to the cluster. The concrete command would depend on the orchestrator of your choice.
Question: I don't understand how the data volumes can be related to the log configuration. If I had data stored in named volumes or host path volumes I would be fine, but I didn't see the relation to my question.
Answer: Correct, functionality-wise, the info regarding volumes is just added for you such that you do not lose data unknowingly / unrecoverably.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With