abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
771 stars 315 forks source link

New volume mount breaks image inheritance #72

Open noelblaschke opened 7 years ago

noelblaschke commented 7 years ago

https://github.com/abiosoft/caddy-docker/commit/7df05c0ba24f048d5d1b6954496984fd78993849#diff-3254677a7917c6c01f55212f86c57fbfR18

This change breaks images which inherit and copy static source updates directly into /srv. Recreating containers with updated images will seemingly not take any effect, because volume mounts on /srv and the old content of existing data volumes overloads the newer ones.

Although you will not change it, it should be mentioned in the readme.

AFAIK there is currently no way to remove volumes from derived images. More on that here: https://github.com/moby/moby/issues/3465

A simple solution is to copy static sources into another directory like /var/www and update your Caddyfile's root to this path.

abiosoft commented 7 years ago

I'm considering reversing that commit.

ckeeney commented 6 years ago

It was already removed once before: https://github.com/abiosoft/caddy-docker/issues/16.

For reference, https://github.com/abiosoft/caddy-docker/issues/67 seems to be the motivation for adding it back in.

Even though this issue has bitten me a few times, I'm all for keeping the volume in the base image. People using Kitematic, etc are just trying to mount static files into this image and should be able to do so easily without having to build their own docker images.

People who are using this image as a base image in their own Dockerfile are already building an image. Updating the root in Caddyfile will not be nearly as big a maintenance headache for these people.

I think documenting the limitation about not making changes to /srv other than mounting files into the volume as well as documenting the solution suggested by @noelblaschke to use a different root is the best solution.

MaksimKlepikov commented 5 years ago

I use this image as a base image in my own Dockerfile. I spent a few hours trying to understand why new images always serve old content. This behavior must be documented.

karthikv commented 5 years ago

Just ran into this issue, took quite some time to realize why this was happening. @abiosoft I think it'd be useful to remove this volume to prevent confusion. Users can always create derivative Dockerfiles that make /srv a volume, but as per @noelblaschke's comment, it's not possible to remove a volume.

Happy to send over a PR if that's easiest! Appreciate all your work on this image, it's been very handy for my personal websites. 👍