Search code examples
dockerplayframeworkdocker-composeboot2dockerdocker-machine

Docker consuming more HD memory


I have a play application and running in docker 1.10.3. We are hitting this applicaton with 1000 request per second to do a load test. Application works fine. We see a significant HD memory consumed by Docker. In 3 day the docker consumed fron 2.2gb to 39gb. This worries us a load.

Docker INFO and the consumed space highlighted enter image description here

Is there any was to configre docker not to consumen HD memory? Any help will be appreciated.


Solution

  • Docker captures the standard output (STDOUT) of your application and stores it (by default) in an internal log file. You can find this file at /var/lib/docker/containers/$CONTAINER_ID/$CONTAINER_ID-json.log. This file is not rotated by default and may grow large if your application prints to STDOUT verbosely.

    Two possible solutions:

    1. Configure log rotation for the Docker log files. I've found a good article here that describes how to enable log rotation for Docker by creating the file /etc/logrotate.d/docker-container with the following contents:

      /var/lib/docker/containers/*/*.log {
        rotate 7
        daily
        compress
        size=1M
        missingok
        delaycompress
        copytruncate
      }
      

      You can play around with the options. They are all documented in logrotate's man page.

    2. Use alternate logging for your containers by specifying the --log-driver option when creating a container:

      $ docker run --log-driver=syslog your_image
      

      Available drivers are documented in the official documentation. You can for example use --log-driver=syslog to use the system's syslog daemon, target various cloud services or disable logging entirely by using --log-driver=none.