Answer the question
In order to leave comments, you need to log in
Docker locks mounted volume?
There is the following situation:
- The spring-boot service writes logs through logback to the output.log file
- Log rotation is configured in logback and it periodically empties output.log, dropping logs into archive files specified in the rotation policy. That is, the output.log itself is such a temporary buffer with the latest log
- All this works great: https://www.youtube.com/watch?v=hrWmfC3y9zM
- But if we mount the folder with logs from the container outside (and we need this is for reading by a third-party utility), then everything breaks down - output.log stops being automatically cleared, grows indefinitely, and the archive files specified in the rotation policy are not created at all. This happens even when nobody reads the file from this directory on the host machine.
Conditionally like this
1) This is inside the container with the service
/app/
|-> service.jar
/app/logs/
|-> output.log
/app/
|-> out1.log
|-> out2.log
volumes:
- /LOGS:/app/logs:rw
volumes:
- /LOGS:/var/log
Answer the question
In order to leave comments, you need to log in
By setting a file as a volume, the kernel will hold a file descriptor to it as long as the container is alive (it will release it only after the server is rebooted, until the Docker daemon is running). Mount directories with logs if you want normal rotation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question