Skip to content
ADD failed: failed to download

ADD failed: failed to download

DodaTech 2 min read

The error “ADD failed: failed to download” occurs when the ADD instruction in a Dockerfile tries to fetch a file from a URL but the download fails for any reason.

What It Means

Docker’s ADD instruction supports downloading files from remote URLs during image build. When the URL is unreachable, the server returns an error, or the download times out, Docker raises this error and aborts the build.

Why It Happens

  • The URL is incorrect or the file was moved or deleted on the server.
  • The remote server requires authentication (e.g., a private S3 bucket).
  • The server returns an HTTP error (404, 403, 500).
  • The Docker build environment has no internet access or is behind a proxy.
  • The URL uses a protocol not supported by ADD (e.g., FTP, SCP).
  • The download times out due to slow network or large file size.

How to Fix It

1. Verify the URL with curl

curl -I https://example.com/file.tar.gz

2. Use RUN with curl or wget instead of ADD

RUN curl -fsSL https://example.com/file.tar.gz -o /tmp/file.tar.gz

3. Configure Docker to use a proxy

# Create ~/.docker/config.json
{
  "proxies": {
    "default": {
      "httpProxy": "http://proxy:8080",
      "httpsProxy": "http://proxy:8080"
    }
  }
}

4. Add authentication credentials

RUN curl -u username:password -fsSL https://private.example.com/file.tar.gz -o /tmp/file.tar.gz

5. Copy the file locally instead

COPY ./local-file.tar.gz /tmp/

FAQ

What is the difference between ADD and COPY for URLs?
ADD supports remote URLs, but this feature is deprecated and unpredictable. COPY does not support URLs. The recommended approach is to use RUN curl for downloads and COPY for local files.
Does ADD support authentication or cookies?
No. ADD does not support authentication headers, cookies, or custom request options. For any non-public download, use RUN curl or RUN wget with the appropriate flags.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro