cannot copy to non-directory:…
- User
cannot copy to non-directory: /dockerfs/docker/overlay2/zoikjccx1uogyz807zso4yjnx/merged/app/node-v12.18.2-linux-x64/node
- Assistant
The error message:
codecannot copy to non-directory: /dockerfs/docker/overlay2/zoikjccx1uogyz807zso4yjnx/merged/app/node-v12.18.2-linux-x64/nodesuggests that during your Docker build or container operation, a
COPYor similar instruction is attempting to copy files into a path that exists but is not a directory, hence the copy operation fails.
Why This Happens
-
When you use a
COPYorADDinstruction in a Dockerfile like:codeCOPY source/path /app/node-v12.18.2-linux-x64/nodeDocker expects the destination to either not exist, or if it exists at that path, to be a directory (if you are copying multiple files/folders).
-
In your case, the destination
/app/node-v12.18.2-linux-x64/nodeexists as a file, not a directory, hence Docker cannot copy multiple files or a directory into it.
Common Scenarios & Fixes
-
Destination is a file, but you are copying multiple files/directories
-
If
nodeis actually a binary or file insidenode-v12.18.2-linux-x64, Docker won't allow copying contents over it as if it were a directory. -
Fix: Change the destination path to the directory containing
node, e.g.:dockerfileCOPY source/path/ /app/node-v12.18.2-linux-x64/or rename the destination so no conflict happens.
-
-
The destination path exists and is a file from a previous layer
-
Sometimes, the problem arises from previously created files in prior layers.
-
Fix: Make sure in your Dockerfile that you are not creating a file at
/app/node-v12.18.2-linux-x64/nodebefore copying. -
If necessary, remove or rename the conflicting file before copying, e.g.:
dockerfileRUN rm -f /app/node-v12.18.2-linux-x64/node COPY source/path /app/node-v12.18.2-linux-x64/node
-
-
- User
RUN mkdir -p /app/namespace &&
mkdir -p /app/cert /app/logs &&
mkdir -p /app/logs /app/config /daca/logs /app/smartcontract/ /app/node-v12.18.2-linux-x64/ADD docker/start.sh dist/indexer.js /app/ COPY ./node-v12.18.2-linux-x64/* /app/node-v12.18.2-linux-x64/
What could be the issue?
- Assistant
- User
Do I keep" mkdir -p /app/logs /app/config /daca/logs /app/smartcontract/ /app/node-v12.18.2-linux-x64/"
If I use: COPY ./node-v12.18.2-linux-x64 /app/node-v12.18.2-linux-x64
- Assistant
Good question!
When you use:
dockerfileCOPY ./node-v12.18.2-linux-x64 /app/node-v12.18.2-linux-x64Docker will create the target directory path if it does not exist. So explicitly running:
dockerfilemkdir -p /app/node-v12.18.2-linux-x64/before the copy is generally not necessary because COPY creates the target folder as needed.
So:
-
You can remove the
mkdir -p /app/node-v12.18.2-linux-x64/line unless you have another reason to create it early. -
The other folders like
/app/logs,/app/config,/daca/logs,/app/smartcontract/— keep those if your app or scripts expect those directories to exist or write logs/data there.
-