Docker Community Forums

Share and learn in the Docker community.

Mounted Files Are Disappearing From Container (Docker-Compose)

(Ryanfitzgerald) #1

Currently, I’m mounting a directory, building it via Docker-compose, then calling up. Initially, all files that are supposed to be present are and they are responding to code changes made locally (i.e. the container’s files are getting updated as they should). However, as soon as I run a command (in this case, I’m running a rails db:migrate command) against the container, the majority of files in the container disappear and only the remaining files stay mounted and responding to code changes.

My Dockerfile is:

FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp

And my docker-compose.yml is:

version: '2'
    image: postgres
        POSTGRES_DB: dev
        POSTGRES_USER: user
        POSTGRES_PASSWORD: password
    build: .
    command: bundle exec rails s -p 3000 -b ''
      - .:/myapp
      - "3000:3000"
      - db

I’m completely out of ideas at this point and can’t figure out why that behavior is occurring, so any help would be greatly appreciated.