title: Docker/Mongodb data not persistent
body: <p>Iam running a rails api server with mongodb all worked perfectly find and I started to move my server into docker.</p>
  
  <p>Unfortunately whenever I stop my server (docker-compose down) and restart it all data are lost and the db is completely empty.</p>
  
  <p>This is my docker-compose file:</p>
  
  <pre><code>version: '2'
  services:
    mongodb:
      image: mongo:3.4
      command: mongod
      ports:
        - "27017:27017"
      environment:
        - MONGOID_ENV=test
      volumes:
        - /data/db
  
    api:
      build: .
      depends_on:
        - 'mongodb'
      ports:
        - "3001:3001"
      command: bundle exec rails server -p 3001 -b '0.0.0.0'
      environment:
        - RAILS_ENV=test
      links:
        - mongodb
  </code></pre>
  
  <p>And this is my dockerfile:</p>
  
  <pre><code>FROM ruby:2.5.1
  RUN apt-get update -qq &amp;&amp; apt-get install -y build-essential libpq-dev nodejs
  
  ENV APP_HOME /app
  
  RUN mkdir $APP_HOME
  
  WORKDIR $APP_HOME
  
  COPY Gemfile* $APP_HOME/
  RUN bundle install
  
  COPY . $APP_HOME
  
  RUN chown -R nobody:nogroup $APP_HOME
  USER nobody
  
  ENV RACK_ENV test
  ENV MONGOID_ENV test
  
  EXPOSE 3001
  </code></pre>
  
  <p>Any idea whats missing here?</p>
  
  <p>Thanks,
  Michael</p>