How to keep Docker container volume files?
<p>I'd like to share <code>~/mydir</code> directory with host, but not replace Docker container directory with host files.
So, I have <code>docker-compose.yml</code></p>

<pre><code>version: '2'
services:
  app:
    container_name: mono
    build: .
    volumes:
      # save .composer files on host to keep cache warmed up
      - '/srv/mono/mydir:/root/mydir'
    command: sleep infinity
</code></pre>

<p>And <code>Dockerfile</code></p>

<pre><code>#/bin/bash
FROM php:5.6

RUN mkdir /root/mydir &amp;&amp; echo '{}' &gt; /root/mydir/myfile.json

VOLUME /root/mydir
</code></pre>

<p>Directory <code>/srv/mono/mydir</code> is empty. It was replaced with host directory. It's clear.</p>

<p>But how to keep original files?</p>

<p>For example it work for MySQL Percona containers:</p>

<pre><code>version: '2'
services:
  percona-56:
    container_name: percona-56
    image: percona/percona-server:5.6
    volumes:
    - /srv/mysql/percona-56:/var/lib/mysql
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
</code></pre>

<p>There are original files from the container:</p>

<pre><code>$ ll /srv/mysql/percona-56
total 176220
    auto.cnf
    error.log
    ibdata1
    ib_logfile0
    ib_logfile1
    init.ok
    mysql
    performance_schema
</code></pre>

<p>I've tried to inspect <a href="https://github.com/docker-library/percona/blob/0366da072fe5dc95af26d8a9f9ace48c72670720/5.6/Dockerfile" rel="noreferrer">Percona Dockerfile</a> but didn't find something related to the volume sharing.</p>

<pre><code>$ docker --version
Docker version 1.12.3, build 6b644ec
</code></pre>