Make Dockerfile VOLUME behave like docker-compose volumes
<p>I am trying to setup a <code>Dockerfile</code> to mount my host directory to my specified docker container directory (so code changes will be reflected immediately). When I run <code>docker run -p 3000:3000 -d -v ~/Projects/test:/app test</code> the files are mounted and everything works fine. However, once I close the container, the file changes don't stay within the container like the changes would if I were running <code>volumes</code> from a <code>docker-compose</code> file.</p>

<p>Here is my Dockerfile:</p>

<pre><code>FROM node:onbuild
EXPOSE 3000
RUN mkdir /app
VOLUME ./:/app/
WORKDIR /app/
RUN npm install -g nodemon
CMD nodemon server.js
</code></pre>

<p>Here is a working docker-compose.yml:</p>

<pre><code>test:
  build: ./
  volumes:
    - ./:/app/
  working_dir: /app/
  command: npm start 
  ports:
    - "3000:3000"
</code></pre>