-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caddyfile file bind mount issues #364
Comments
The current documentation at https://hub.docker.com/_/caddy suggests putting the custom Caddyfile inside a conf directory that is mounted inside /etc/caddy/ To override the default Caddyfile , you can create one in the subfolder conf at $PWD/conf/Caddyfile and mount this folder at /etc/caddy:
This should take care of the situation you describe. |
It should be noted that you need to provide a new command to get caddy to use this Caddyfile in the container. The service in a docker compose file might look like this:
|
You can mount the folder and no custom command is required (only if you want to use a different location): # Image has only the Caddyfile at this location:
$ docker run --rm -it caddy:2.8 ls /etc/caddy
Caddyfile
# Check image ENTRYPOINT and CMD directives:
$ docker inspect caddy:2.8 | jq '.[0].Config | { entrypoint: .Entrypoint , cmd: .Cmd | join(" ") }'
{
"entrypoint": null,
"cmd": "caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"
} Direct file mount (valid, so long as you don't expect any changes while the container is running to be received): services:
reverse-proxy:
image: caddy:2.8
# File bind mount:
volumes:
- ./config/Caddyfile:/etc/caddy/Caddyfile:ro Bind mount volume (better when you expect changes on the host to be in sync with the copy in the container): services:
reverse-proxy:
image: caddy:2.8
# Folder bind mount:
volumes:
- ./config:/etc/caddy:ro NOTE:
|
The documentation has been updated to that effect just recently without referencing this issue. I'm therefore closing this issue as done. |
For reference, that is the commit by their CI running Ah I see you just referenced this issue from the associated one that PR mentions 😅 |
The current documentation suggests mounting the Caddyfile as a file:
This approach can lead to issues due to how Docker handles file binds. When an individual file is mounted into a container, Docker mounts the inode of the file on the Linux filesystem. If the file is replaced (which many editors do), the inode changes. Thus it can happen that writes to the file after starting the container won't be reflected between the inside and outside of the container.
For more detailed information, refer to this Docker issue: moby/moby#6011
To avoid such issues, it is often suggested mount the parent directory instead of relying on single file bind mounts.
with the file tree
It would make sense update the documentation accordingly or at least incorporate a warning about this docker issue with file mounts.
The text was updated successfully, but these errors were encountered: