Avoid persisting mongo data in docker-compose

I’m using docker compose to run tests for my application. The configuration looks like:

version: '2'

    build: .
    image: myapp:web
      - "3000:3000"
      - mongo
      - mongo
    image: mongo:3.2.6

Right now, when I run docker-compose up, there is a volume created automatically (by docker-compose or the mongo image?) which maps the Mongo storage data to path like: /var/lib/docker/volumes/c297a1c91728cb225a13d6dc1e37621f966067c1503511545d0110025479ea65/_data.

  • “org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean” Using docker
  • Vagrant + puppet + docker
  • How can I mount a file in a container, that isn't available before first run?
  • Can not ping docker container from another host which is in the same LAN
  • Running a script from a mongodb docker-container
  • Docker Compose Error “TypeError: expected string or buffer” on docker:dind (ports)
  • Since I am running tests rather than production code, I’d actually like to avoid this persistence (the mongo data should go away when the docker-compose exits) — is this possible? If so, what’s the best way to do it?

  • Monitor Docker container with Zabbix
  • How to pull signed docker images using dockerode NodeJS API
  • Advice needed on how to setup a SAAS service for a php based application
  • Docker can't find a script that I COPY to an image when I try to invoke it twice via /script.sh && /script.sh (but once works!)
  • Go Web app on AWS with Elastic Beanstalk not showing output in logs
  • How do I define the name of image built with docker-compose
  • One Solution collect form web for “Avoid persisting mongo data in docker-compose”

    After the containers exit (or you stop them with a down command), clean up the old containers and volumes with

      docker-compose rm -v

    The -v tells it to also remove the volumes (container volumes and named volumes created with docker-compose, but not host volumes).

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