A Docker image for Caddy. This image includes cors, ipfilter, realip, expires and cache plugins.
Plugins can be configured via the plugins
build arg.
Check abiosoft/caddy:builder for generating cross-platform Caddy binaries.
This image is built from source code. As such, it is subject to the project's Apache 2.0 license, but it neither contains nor is subject to the EULA for Caddy's official binary distributions.
Thanks to the original author @abiosoft for providing the abiosoft/caddy-docker repository!
Caddy may prompt to agree to Let's Encrypt Subscriber Agreement. This is configurable with ACME_AGREE
environment variable. Set it to true to agree. ACME_AGREE=true
.
$ docker run -d -p 2015:2015 siwecos/caddy
Point your browser to http://127.0.0.1:2015
.
Be aware! If you don't bind mount the location certificates are saved to, you may hit Let's Encrypt rate limits rending further certificate generation or renewal disallowed (for a fixed period)! See "Saving Certificates" below!
Save certificates on host machine to prevent regeneration every time container starts. Let's Encrypt has rate limit.
$ docker run -d \
-v $(pwd)/Caddyfile:/etc/Caddyfile \
-v $HOME/.caddy:/root/.caddy \
-p 80:80 -p 443:443 \
abiosoft/caddy
Here, /root/.caddy
is the location inside the container where caddy will save certificates.
Additionally, you can use an environment variable to define the exact location caddy should save generated certificates:
$ docker run -d \
-e "CADDYPATH=/etc/caddycerts" \
-v $HOME/.caddy:/etc/caddycerts \
-p 80:80 -p 443:443 \
abiosoft/caddy
Above, we utilize the CADDYPATH
environment variable to define a different location inside the container for
certificates to be stored. This is probably the safest option as it ensures any future docker image changes don't interfere with your ability to save certificates!
Caddyfile: /etc/Caddyfile
Sites root: /srv
Note that this does not work on local environments.
Use a valid domain and add email to your Caddyfile to avoid prompt at runtime.
Replace mydomain.com
with your domain and [email protected]
with your email.
mydomain.com
tls [email protected]
Thanks to the original author @abiosoft for providing the abiosoft/caddy-docker repository!
Thanks to @mholt and the caddy community for creating Caddy