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

  • docker-compose restart inverval
  • Docker php starting containers with parameters
  • How to prevent docker images on docker hub being overwritten
  • Trouble accessing Kubernetes endpoints
  • How can you run multiple docker containers from your computer, and have each use a different IP (using a VPN)?
  • Problems accessing multiple docker containers remotely
  • 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 !!!

  • Docker - Tomcat and PostgreSQL containers in same host - No Route to host
  • Docker public network configuration
  • C source files not allowed when not using cgo or SWIG: sqlite3-binding.c
  • Ansible Variables only X times per host
  • error during connect: … http: server gave HTTP response to HTTPS client on any docker command with remote host
  • Docker VS Native installation on a server. How to recover from downtime mysql/mariadb without data lloss
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.