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.

  • Pull jobs directory from a repository into Jenkins from a Dockerfile
  • Docker create a test machine
  • Is there a way to remove a name from a Docker container?
  • Redis Sentinel manual failover command timesout
  • Docker Configuration´╝Üdocker.service vs daemon.json
  • Difference between Docker container and service
  • $ 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.

  • Kubernetes Limits (1.2) not enforced
  • docker RUN append to /etc/hosts in Dockerfile not working
  • Unable to finding the option to set docker workspace option when running the docker image
  • Communication between spring boot dockerized apps
  • docker-compose doesn't build image from latest commit of git repository
  • How to serve Docker containers with Nginx if there are multiple sites on one host?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.