1. Caddy version (caddy version
): v2.3.0
2. How I run Caddy:
export CADDY_DATA_DIR=/var/containerdata/caddy
export CDN_DATA_DIR=/var/containerdata/cdn
docker-compose up -d
a. System environment:
Ubuntu 20.04 LTS x64
Intel Xeon 2 GHz
Docker version 19.03.8, build afacb8b7f0
docker-compose version 1.26.2, build eefe0d31
b. Command:
c. Service/unit/compose file:
---
version: "3.8"
configs:
caddy-basic-content:
file: ./Caddyfile
labels:
caddy:
services:
caddy:
image: "lucaslorentz/caddy-docker-proxy:2.3.4-alpine"
# image: docker.nexus.mydomain.com:8084/caddy:custom
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
ports:
- "80:80"
- "443:443"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "$CADDY_DATA_DIR:/data"
- "$CDN_DATA_DIR:/var/www/cdn"
networks:
- my-network
whoami:
image: "containous/whoami"
deploy:
replicas: 1
placement:
constraints: [node.role == manager]
labels:
caddy: whoami.mydomain.com
caddy.reverse_proxy: "{{upstreams 80}}"
caddy.basicauth.admin: "dsfafdfadsafdsfasdfdsfdsadfsa"
networks:
- my-network
d. My complete Caddyfile or JSON config:
cdn.mydomain.com {
root * /var/www/cdn
file_server browse
}
e. My complete Dockerfile
Dockerfile
FROM caddy:2.3.0-builder AS builder
RUN xcaddy build v2.3.0 \
--with github.com/lucaslorentz/caddy-docker-proxy/plugin/v2@latest
FROM caddy:2.3.0
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
3. The problem I’m having:
There seems to be some special knowledge required for building a custom caddy image which I am not aware of. I thought using xcaddy was enough?
4. Error messages and/or full log output:
The container logs are different between my custom image and the original docker-proxy image.
Custom container log:
{"level":"info","ts":1620038370.6904325,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
{"level":"info","ts":1620038370.6983402,"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":1620038370.7012806,"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":1620038370.7017667,"msg":"autosaved config","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1620038370.701776,"msg":"serving initial configuration"}
{"level":"info","ts":1620038370.7026994,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00082aa10"}
{"level":"info","ts":1620038370.711999,"logger":"tls","msg":"cleaned up storage units"}
Obviously https does not work, this might be the problem. But I haven’t changed configs, only the caddy image is different.
Basically there must be something missing about xcaddy
builds which I am not aware of.
5. What I already tried:
I’ve looked at the Dockerfile
from caddy-docker-proxy
and added those lines at the end of my own Dockerfile
:
ENTRYPOINT ["/bin/caddy"]
CMD ["docker-proxy"]
Nothing changed.
==> Update: The entrypoint must be “/usr/bin/caddy” according to the Dockerfile above. Then it worked!
Is there a “standard” path for caddy?