Answer the question
In order to leave comments, you need to log in
How do they copy files from docker to the host when creating a container?
FROM alpine:latest
ENV ROOT_DIRECTORY=/caddyserver
ENV CONF_DIRECTORY=/caddyserver/cfg
ENV WWW_DIRECTORY=/caddyserver/www
ENV LOGS_DIRECTORY=/caddyserver/logs
#ARG Plugins='http.cache,net,http.git,http.ipfilter'
VOLUME $CONF_DIRECTORY $WWW_DIRECTORY $LOGS_DIRECTORY
RUN apk add --no-cache openssh-client git
ENV Email=''
ENV CPU=''
EXPOSE 80 443 2015
CMD $ROOT_DIRECTORY/caddy -conf $ROOT_DIRECTORY/cfg/Caddyfile -log $ROOT_DIRECTORY/logs/caddy.log -cpu $CPU -email $EMAIL -agree
docker create \
--name=caddy \
-v /opt/Docker/caddy/cfg:/caddyserver/cfg \
-v /opt/Docker/caddy/www:/caddyserver/www \
-v /opt/Docker/caddy/logs:/caddyserver/logs \
-e [email protected] -e CPU=2 \
-p 80:80 -p 443:443 -p 2015:2015 \
caddy
Answer the question
In order to leave comments, you need to log in
No way.
More precisely, only if someone in the container overwrites them if there are no files.
And the standard mount behaves exactly the same - no magic "merge"
Because there is another subscriber to the question, I’ll add what I found
After ventilating this question, I came across the following, as done by linuxserver.io
Creating an image based on their alpine image ( which, by the way, you can pass PUID and GUID for files and folders with parameters ), the necessary configuration files we put it in the right folder (they usually do it in the defaults folder), then we create the 20-config file along the path /etc/cont-init.d/ and add the necessary conditions there
#!/usr/bin/with-contenv bash
# make folders
mkdir -p \
/caddyserver/{cfg,logs,www}
# copy config
&& cp \
/defaults/Caddyfile /caddyserver/cfg/Caddyfile
# permissions
chown -R abc:abc \
/caddyserver
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question