Avoid persisting mongo data in docker-compose

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

version: '2'

services:
  web:
    build: .
    image: myapp:web
    ports:
      - "3000:3000"
    depends_on:
      - mongo
    links:
      - 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.

  • Docker 1.12 swarm service add volumes
  • Separate specific configuration in Dockerfile
  • Salt minion inside docker container?
  • Collect UDP(Gelf) messages and forward with TCP to logstash
  • Tomcat 7 fails when starts in Debian, but continue working in background
  • How make a cluster of CoreOS on my local infrastructure?
  • 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?

  • Ruby: Catching Sequel::DatabaseConnectionError
  • How to edit source code of a python project deployed in docker
  • How to answer command line prompts in script in docker
  • Docker volume created with nfs server is not reflecting the data from nfs server
  • application(JMX) monitoring running inside kubernetes cluster using prometheus
  • Google Magenta (muisc/ML) docker image for running with GPU?
  • 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.