My docker image contain files in directory /data
When I run docker container with named or unnamed volume associated with this directory volume is populated with files from image (as it sould be).
But when I try to put volume to specific path like:
volumes:
- ./data:/data
Host directory ./data is not populated witch files from image it is empty. (but accessible from container).
Is there some difference between creation of named, unnamed volumes and volumes in specific host path that explains this behavior?
My dockrefile:
FROM hypriot/rpi-alpine
RUN apk update && \
apk upgrade && \
apk add --no-cache bash minidlna && \
rm -rf /var/cache/apk/*
RUN mkdir /data %% \
mkdir /data/log && \
mkdir /data/db
COPY minidlna.conf /data/minidlna.conf
COPY minidlna.conf /minidlna.conf
COPY entrypoint.sh /entrypoint.sh
VOLUME ["/data"]
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
and docker-compose.yml
version: "3"
services:
minidlna:
image: silvan85/rpi-minidlna
volumes:
- ./data:/data
- /media/ExternalHDD/media:/media
network_mode: "host"
restart: unless-stopped
When you mount a host directory into container, the contents of host directory shadow the contents of container.
Please see mount files present in a directory in docker image with the directory in the host