You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Dockerfile COPY指令显式引用文件失败,Heroku容器构建报错

Heroku Container Push --recursive Build Failure Troubleshooting

Project Structure

├── compose
│   ├── local
│   │   └── django
│   │       ├── Dockerfile
│   │       ├── celery
│   │       │   ├── beat
│   │       │   │   └── start.sh
│   │       │   └── worker
│   │       │       └── start.sh
│   │       └── start.sh
│   └── production
│       ├── caddy
│       │   ├── Caddyfile
│       │   └── Dockerfile.caddy
│       └── django
│           └── Dockerfile.django

Issue

When running $ heroku container:push --recursive from the root directory, the build fails with an error starting with:

Sending build context to Docker daemon 3.072kB
Step 1/2 : FROM abiosoft/caddy:0.10.6...

Root Causes & Fixes

1. Non-Standard Dockerfile Names Are Not Detected by --recursive

Heroku's --recursive flag scans directories for files named exactly Dockerfile—it won't automatically pick up Dockerfile.caddy or Dockerfile.django.

Fix:

Either:

  • Rename your custom Dockerfiles to Dockerfile (e.g., rename Dockerfile.caddy to compose/production/caddy/Dockerfile), then re-run heroku container:push --recursive.
  • Or push each service individually with the --file flag to specify the custom Dockerfile:
    # Push Django production service
    heroku container:push web --file compose/production/django/Dockerfile.django
    # Push Caddy service
    heroku container:push caddy --file compose/production/caddy/Dockerfile.caddy
    

2. Outdated/Unavailable Caddy Image

The abiosoft/caddy:0.10.6 image is extremely old (released in 2018) and has likely been removed from Docker Hub, causing a pull failure during build.

Fix:

Replace the outdated base image in Dockerfile.caddy with the official, actively maintained Caddy image. For example, use the latest Alpine-based stable build:

# Replace this line
# FROM abiosoft/caddy:0.10.6
# With this
FROM caddy:2-alpine

You can adjust the tag to match your needs (e.g., caddy:2.7-alpine for a specific minor version).

3. Build Context Path Mismatches

When running the push from the root directory, the Docker build context is the root folder. If your Dockerfiles use COPY/ADD commands that reference paths relative to the Dockerfile's directory, those paths will break because Docker looks for files relative to the build context (root).

Fix:

Update all COPY/ADD commands in your Dockerfiles to use paths relative to the root directory. For example, in Dockerfile.caddy, instead of:

COPY Caddyfile /etc/caddy/Caddyfile

Use:

COPY compose/production/caddy/Caddyfile /etc/caddy/Caddyfile

内容的提问来源于stack exchange,提问作者Jay Jung

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:39:54