Skip to content
Latchkey

Docker "ADD failed: failed to get destination" in CI

An ADD instruction could not resolve where to put its content. The destination path cannot be created - usually because a path component is a file instead of a directory, or the destination is malformed.

What this error means

An ADD step fails with ADD failed: failed to get destination for <path>. The source may be fine; Docker cannot prepare the target directory.

docker
ADD failed: failed to get destination for /app/data/file.txt:
not a directory
# /app/data exists as a file, so /app/data/file.txt has no valid parent

Common causes

A parent path component is a file

If /app/data is a file, ADD x /app/data/file.txt cannot create file.txt under it - the parent must be a directory.

Malformed or relative destination with no WORKDIR

A relative destination with an unset or surprising WORKDIR, or a destination that is otherwise invalid, leaves Docker unable to resolve the target.

How to fix it

Ensure the destination parent is a directory

Create the directory first, or fix the earlier step that made it a file.

Dockerfile
RUN mkdir -p /app/data
ADD file.txt /app/data/file.txt

Use an absolute destination and set WORKDIR

Give ADD an unambiguous absolute destination.

Dockerfile
WORKDIR /app
ADD ./assets/ /app/assets/

How to prevent it

  • Create destination directories with mkdir -p before ADD/COPY into them.
  • Use absolute destination paths and a defined WORKDIR.
  • Prefer COPY for plain file copies; reserve ADD for URLs/tarballs.

Frequently asked questions

What causes ""ADD failed: failed to get destination""?
If /app/data is a file, ADD x /app/data/file.txt cannot create file.txt under it - the parent must be a directory.
How do I fix "ADD failed: failed to get destination"?
Create the directory first, or fix the earlier step that made it a file.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card