I am trying to create a volume for LEMP application called “/data”.
My build works if I don’t mount the host machine (my Macbook) to it with the -v. I have spent 1/2 day on -v vs -mount and so on.
My understanding is if I defined a volume that the information will be copied to the Volume mount location on first boot. If I start my docker image it will come up and the files and directories are there.
If I run it with -v /MyHostData:/data then it is empty. I understand from the documentation that the host directory is mounted on top of the local directory (hence empty the first time). But isn’t it supposed to copy the volume information over to the directory on first boot.
I pushed the image up to docker: cbitterfield/lemp-ubuntu18-04:v1.1
Can someone provide some clarity on this issue?
… snip (Dockerfile)
FROM ubuntu:18.04
USER root
…
RUN mkdir /data
RUN mkdir /data/html
RUN mkdir /data/mysql
RUN (mkdir /data/logs; mkdir /data/logs/nginx;mkdir /data/logs/mysql)
RUN (mkdir /data/conf;mkdir /data/conf/nginx_sites-available;mkdir /data/conf/nginx_sites-enabled;mkdir /data/conf/nginx_conf.d; mkdir /data/conf/mysql;mkdir /data/conf/tls)
…
VOLUME /data
OSX 10.14.x (Host OS)
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:22:34 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:29:19 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683