Docker to store an application(service) logs in a folder and purge them on a timely basis
I just had a query of storing the logs of a service/application in a separate folder and purge them frequently.
We use Docker in Webmin server to deploy our Spring boot Application. we would like to achieve the above to prevent the space mess in webmin server
Below is a sample command we use to build and run the service,
docker build -t application-service:latest ./application-service docker run -p 1070:1070 -m 128m -d application-service
I used “-m” for memory allocation of a service And, I just wonder, is there any key to store the logs of the application in different path and any other things which i can do in docker or webmin server to purge the logs in that particular location
Thanks in advance !!! Awaiting for a suggestion !!!
One Solution collect form web for “Docker to store an application(service) logs in a folder and purge them on a timely basis”
Docker has a number ways of handling the container logs. You can read about them here.
All you need is to provide the logging driver you need, while you call
docker run with the
--log-driver flag specifying the driver and it’s configuration.
One more possible solution is to use mounted volumes and configure your service, which is running within container, to store it’s logs into the folder, which should be mounted. In that case, you will have access to the logs in your host-machine.