I'd like to share ~/mydir
directory with host, but not replace Docker container directory with host files.
So, I have docker-compose.yml
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
And Dockerfile
#/bin/bash
FROM php:5.6
RUN mkdir /root/mydir && echo '{}' > /root/mydir/myfile.json
VOLUME /root/mydir
Directory /srv/mono/mydir
is empty. It was replaced with host directory. It's clear.
But how to keep original files?
For example it work for MySQL Percona containers:
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'
There are original files from the container:
$ ll /srv/mysql/percona-56
total 176220
auto.cnf
error.log
ibdata1
ib_logfile0
ib_logfile1
init.ok
mysql
performance_schema
I've tried to inspect Percona Dockerfile but didn't find something related to the volume sharing.
$ docker --version
Docker version 1.12.3, build 6b644ec