issue with volumes
Hi @tiredofit
I am in the process of creating a domain-joined printserver. Resulting in running these services:
- cupsd
- smbd (samba)
- avahi
- nmbd (samba)
my issue is now that I want/need to persist a lot of stuff and we do hostmounting in our environment. But when I do this in the docker-compose.yml
volumes:
- /var/lib/docker/compose/cups101/config/cups:/etc/cups
- /var/lib/docker/compose/cups101/config/samba:/etc/samba
# - /var/lib/docker/compose/cups101/spool:/var/spool/cups
- /var/lib/docker/compose/cups101/log/cups:/var/log/cups
- /var/lib/docker/compose/cups101/log/samba:/var/log/samba
the container will not "use" the mapped/mounted folders. How can I allow for my image to use mapped folders in my container?
All looks really good with the bind mounts in your volumes - Unless the applications null out the contents of the folder your outside (var/lib) should be mapping into your paths in the container without issue. Does this only happen with this image?
when I read my issue now it is really misleading in describing the issue.
The mounted folders generally work. BUT: the mounts are connected but empty. That results in empty folders like "/etc/cups" within the container. That means the services have no config files to run.
Normally I was expecting the contents of the containers to "transfer" over to the mount. but that does not happen.
Mounts/Volumes do work for us. But I have not mounted folders into your images so far. only single files
You'll during build time want to create seed folders to move the stuff out of the way if going to expose a bind mount that way - The hosts contents will always override the containers thus creating the blank files.
Alternatively I believe you can take advantage of the VOLUME command within the Dockerfile which should allow for better persistence. I see issues with it and actively avoid it and prefer the seed approach.
Random snippets:
dockerfile..
mkdir -p /assets/<image_name>/etc
cp -aR /etc/cups /assets/<image_name>/etc
init..
if dir_empty /etc/cron ; then
mkdir -p /etc/cron
cp -aR /assets/<image_name>/etc/cron /etc
chown -R user:group /etc/cron
fi
dirty, but thats generally how i've been building images..