By default caddy is using its default configuration from /etc, it’s just ignoring the ENV variable pointing to docker volume mountpoint
The solution I’ve found to be working is to change the default command.
This behaviour is not mentioned on the dockerhub page and you have to check the default container cmd line to understand why your config is not working.
The ENV variables look fine to me, assuming that portainer isn’t lying to me:
1. Caddy version (caddy version
):
2. How I run Caddy:
I’m running it in docker container
docker run -d -p 80:80 -p 443:443 -v static_otherdomain.tld:/websites/otherdomain.tld -v static_funnydomain.tld/websites/funnydomain.tld -v caddy_data:/data -v caddy_config:/config caddy:2.3.0-alpine
a. System environment:
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
b. Command:
docker run -d -p 80:80 -p 443:443 -v caddy_data:/data -v caddy_config:/config caddy:2.3.0-alpine
c. Service/unit/compose file:
Just plain docker command and config in a separate volume
d. My complete Caddyfile or JSON config:
/var/lib/docker/volumes/caddy_config/_data/caddy# cat caddyfile
subdomain.funnydomain.tld {
respond "subdomain.funnydomain.tld"
}
git.funnydomain.tld {
reverse_proxy 172.19.0.2:3000
}
www.funnydomain.tld, funnydomain.tld {
reverse_proxy 172.19.0.2:3000
}
www.otherdomain.tld, otherdomain.tld {
root * /websites/otherdomain.tld
file_server
}
3. The problem I’m having:
Caddy listens only on http port (port 80) no attempt to generate ssl cert is being made and connections to port 443 timeout since it’s not listening on that port.
4. Error messages and/or full log output:
{"level":"info","ts":1612042946.67578,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"},
{"level":"info","ts":1612042946.676735,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["localhost:2019","[::1]:2019","127.0.0.1:2019"]},
{"level":"info","ts":1612042946.6772525,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80},
{"level":"info","ts":1612042946.6775215,"msg":"autosaved config","file":"/config/caddy/autosave.json"},
{"level":"info","ts":1612042946.677561,"msg":"serving initial configuration"},
{"level":"info","ts":1612042946.6777406,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0001ff1f0"},
{"level":"info","ts":1612042946.6818185,"logger":"tls","msg":"cleaned up storage units"},
5. What I already tried:
Changing the default command line argument to point to the configuration on docker volume seems to be working