Official Image under Docker under Debian 11 (under Proxmox VM in amd64 architecture)
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
c. Service/unit/compose file:
d. My complete Caddy config:
3. The problem I’m having:
Not a problem. I would like to know if it is possible to automatically restart Caddy when I change the config, i.e. the Caddyfile.
4. Error messages and/or full log output:
5. What I already tried:
There are other recommendation for this results but they are for Caddy run directly on a host machine and use systemd. I can’t configure this on the host machine, so I’m searching for a solution at the container level.
Actually I’m killing and restarting caddy manually
Yep. It’s not exactly a rollback though, because the new config is not actually active until after it’s loaded successfully. The old config continues to run until after the new config is already started. See Architecture — Caddy Documentation
The caddy reload command that I mentioned earlier does it the same way.
The thing is that --watch is not optimal for performance because it uses polling to check if the config file changed. That means there will always be some CPU/disk activity from Caddy on an interval to check if the config changed. This is minor, but it might matter depending on your needs.