
Caddy 2 is out and now has an https://hub.docker.com/_/caddy, please use that.
A Docker image for Caddy. This image includes the git and cloudflare plugins. Plugins can also be configured via the plugins build arg.
A big thank you to https://github.com/abiosoft/caddy-docker whos this image is forked off.
! See "Saving Certificates" below!
Save certificates on host machine to prevent regeneration every time container starts. Let's Encrypt has rate limit.
sh$ docker run -d \ -v $(pwd)/Caddyfile:/etc/Caddyfile \ -v $HOME/.caddy:/root/.caddy \ -p 80:80 -p 443:443 \ adriel/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:
sh$ docker run -d \ -e "CADDYPATH=/etc/caddycerts" \ -v $HOME/.caddy:/etc/caddycerts \ -p 80:80 -p 443:443 \ adriel/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!
:[<version>-]php variant of this image bundles PHP-FPM alongside essential php extensions and composer. e.g. :php, :0.10-php
sh$ docker run -d -p 2015:2015 adriel/caddy:php
Point your browser to http://127.0.0.1:2015 and you will see a php info page.
Local php source
Replace /path/to/php/src with your php sources directory.
sh$ docker run -d -v /path/to/php/src:/srv -p 2015:2015 adriel/caddy:php
Point your browser to http://127.0.0.1:2015.
Note
Your Caddyfile must include the line on startup php-fpm7. For Caddy to be PID 1 in the container, php-fpm7 could not be started.
Caddy can talk to Cloudflare via their API to automaticly confugure/update your Let's Encrypt certificates using the Cloudflare plugin (which has been included in this image).
Follow the instrutions here to set it up.
Caddy can serve sites from git repository using git plugin.
Create Caddyfile
Replace github.com/adriel/webtest with your repository.
sh$ printf "0.0.0.0\nroot src\ngit github.com/adriel/webtest" > Caddyfile
Run the image
sh$ docker run -d -v $(pwd)/Caddyfile:/etc/Caddyfile -p 2015:2015 abiosoft/caddy
Point your browser to http://127.0.0.1:2015.
Default Caddyfile
The image contains a default Caddyfile.
0.0.0.0 browse fastcgi / 127.0.0.1:9000 php # php variant only startup php-fpm7 # php variant only
The last 2 lines are only present in the php variant.
Paths in container
Caddyfile: /etc/Caddyfile
Sites root: /srv
Using local Caddyfile and sites root
Replace /path/to/Caddyfile and /path/to/sites/root accordingly.
sh$ docker run -d \ -v /path/to/sites/root:/srv \ -v path/to/Caddyfile:/etc/Caddyfile \ -p 2015:2015 \ abiosoft/caddy
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 user@host.com with your email.
mydomain.com tls user@host.com
Run the image
You can change the the ports if ports 80 and 443 are not available on host. e.g. 81:80, 444:443
sh$ docker run -d \ -v $(pwd)/Caddyfile:/etc/Caddyfile \ -p 80:80 -p 443:443 \ abiosoft/caddy
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。




探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
不支持 push
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务