Limit Disk usage in Docker+MongoDB

I am using the official mongo Docker image to start a MongoDB container where my boot disk is limited (e.g. 10G) I configured the docker to run with Google Cloud Logging driver and was hoping Google to store all the logs and save my local disk space. However, I notice the disk continues to grow:

$ df -h
/dev/sda1       9.9G  4.5G  4.9G  49%

As I digged deeper I realized the size of docker containers seems to be growing over time.

  • How to disable password login through ssh for root, while allowing certificate based login
  • Docker's `docker0` device dies repeatedly (`inet addr` disappears)
  • DC/OS and concurrent deployments
  • Is it possible to start multi physical node hadoop clustster using docker?
  • Host screen turns off when I start X server in docker container
  • How to run basic web app container in docker-py?
  • $ sudo du -sh /var/lib/docker/
    3.6G    /var/lib/docker/

    However, I can’t go further as somehow I can’t access the directories within.

    If I go inside the docker and du -sh the root, I don’t find any suspicious directories occupying space.

    So my problem is how do I find out where the disk space is used and how do I eliminate it.

    My docker startup command (shown without project options)

    docker run -d --log-driver=gcplogs mongo mongod

    EDIT: I noticed the size growing has stopped at 4.5GB from ~3GB for a while. So I supposed it has reached some equilibrium now.

  • Docker task starting then stopping without any error
  • How do I create a Docker container with a hostname that an other container can use?
  • Cannot use mongodb (docker) with Symfony 3
  • Apache Marathon: Pod/Compose like?
  • (spotify) Maven docker builder for Java
  • How do I restart a Docker container/image/machine?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.