caddy-docker icon indicating copy to clipboard operation
caddy-docker copied to clipboard

Caddyfile file bind mount issues

Open msladek opened this issue 1 year ago • 0 comments

The current documentation suggests mounting the Caddyfile as a file:

volumes:
  - $PWD/Caddyfile:/etc/caddy/Caddyfile

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: https://github.com/moby/moby/issues/6011

To avoid such issues, it is often suggested mount the parent directory instead of relying on single file bind mounts.

volumes:
  - $PWD/etc:/etc/caddy

with the file tree

├── compose.yml
└── etc
    └── Caddyfile

It would make sense update the documentation accordingly or at least incorporate a warning about this docker issue with file mounts.

msladek avatar Aug 02 '24 16:08 msladek