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.

  • docker: networking without linking
  • Docker refusing to run bash
  • Can I run a bash script from a file in a separate docker volume before a container starts?
  • On kubernetes helm how to replace a pod with new config values
  • Deploying Elixir App to Google Cloud via Docker
  • Is it possible to bind multiple folders in Docker?
  • $ 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.

  • Using host JVM to run jar inside a docker container
  • Docker-compose: close ports after SIGTERM
  • Docker inter-container routing
  • Can't discover docker container on user defined network
  • How to deploy my asp mvc website to Docker container
  • Docker compose version 2 volumes not using specified location
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.