COPY failed: stat /var/lib/docker/tmp/docker-xxx : no such file or directory
When you run
docker build . --file backend/Dockerfile ...
The path argument .
becomes the context directory. (Docker actually sends itself a copy of this directory tree, which is where the /var/lib/docker/tmp/...
path comes from.) The source arguments of COPY
and ADD
instructions are relative to the context directory, not relative to the Dockerfile.
If your source tree looks like
.
+-- backend
| \-- Dockerfile
\-- target
\-- demo-0.0.1-SNAPSHOT.jar
that matches the Dockerfile you show. But if instead you have
.
+-- backend
+-- Dockerfile
\-- target
\-- demo-0.0.1-SNAPSHOT.jar
you'll get the error you see.
If you don't need to refer to anything outside of the context directory, you can just change what directory you're passing to docker build
COPY target/demo-0.0.1-SNAPSHOT.jar /opt/demo-0.0.1/lib/demo-0.0.1-SNAPSHOT.jar
docker build backend ...
Or, if you do have other content you need to copy in, you need to change the COPY
paths to be relative to the topmost directory.
COPY backend/target/demo-0.0.1-SNAPSHOT.jar /opt/demo-0.0.1/lib/demo-0.0.1-SNAPSHOT.jar
COPY common/config/demo.yml /opt/demo-0.0.1/etc/demo.yml
docker build . -f backend/Dockerfile ...
Jenkins-Run Docker: COPY failed: stat /var/lib/docker/tmp/docker-builder...: no such file or directory
Your comment # fails on this line
is the problem.
As per the Docker documentation:
Docker treats lines that begin with # as a comment, unless the line is
a valid parser directive. A # marker anywhere else in a line is
treated as an argument.
More info here: https://docs.docker.com/engine/reference/builder/#format
How to fix error COPY failed: stat /var/lib/docker/tmp/docker-builder/public: no such file or directory
As David hinted in the comments, this command looks like it came from an ONBUILD instruction from the base image. Since nginx doesn't ship with that command, this points to another image on the host that was tagged as nginx. Pulling a fresh copy of nginx from upstream can fix that:
docker pull nginx
COPY failed: stat /var/lib/docker/tmp/docker-buildernum/server/requirements.txt: no such file or directory
After looking at the example project more closely, which has the same structure as what I'm trying to do, I ended up copying its Dockerfile
formatting. I ended up with this which is working fine:
FROM python:3.7-slim
ENV PYTHONUNBUFFERED 1
WORKDIR /app
EXPOSE 5000
COPY requirements*.txt ./
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "manage.py", "collectstatic"]
CMD ["gunicorn", "-b", ":5000", "--log-level", "info", "config.wsgi:application"]
Related Topics
Cuda - Confusion About The Visual Profiler Results of "Branch" and "Divergent Branch" (2)
Change The Escape Sequence Generated by Xterm for Key Combinations
Aosp Build Error: Unrecognized Module Type "Hidl_Package_Root"
Git Is Not Ignoring File Permission Changes
/Usr/Bin/Ld: Cannot Find -Lemu
Run Random Command in Bash Script
Grep If The Next X Lines Doesn't Contain a Specific String
Command Execution with Nohup in Background
Linux Select() and Fifo Ordering of Multiple Sockets
Grep,How to Search for Exact Pattern
How to Know If I Can Compile with Fma Instruction Sets
Kaldi Toolkit Installation Error on Ubuntu 16.04
Reducing Privileges of a Process on Unix or Gnu/Linux
Inconsistent Systemd Startup of Freeswitch