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.
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 parentCommon 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.
RUN mkdir -p /app/data
ADD file.txt /app/data/file.txtUse an absolute destination and set WORKDIR
Give ADD an unambiguous absolute destination.
WORKDIR /app
ADD ./assets/ /app/assets/How to prevent it
- Create destination directories with
mkdir -pbefore ADD/COPY into them. - Use absolute destination paths and a defined WORKDIR.
- Prefer COPY for plain file copies; reserve ADD for URLs/tarballs.