There is a directory inside the stain/jena-fuseki:4.0.0 image that cannot be copied while other directories can be. I have the following Dockerfile
FROM python:3.8.15-slim
COPY --from=stain/jena-fuseki:4.0.0 /fuseki /fuseki
If I run docker image build .
I get the following response
Sending build context to Docker daemon 435.9MB
Step 1/2 : FROM python:3.8.15-slim
---> f0fe0cb74bac
Step 2/2 : COPY --from=stain/jena-fuseki:4.0.0 /fuseki /fuseki
COPY failed: stat fuseki: file does not exist
However, I looked into the image with docker run -it stain/jena-fuseki:4.0.0
and the directory does exist at the root level along with other directories which are copyable. E.g. following Dockerfile builds perfectly without any errors.
FROM python:3.8.15-slim
COPY --from=stain/jena-fuseki:4.0.0 /jena-fuseki /jena-fuseki
I have tried many things like changing the working directory with WORKDIR /
and also things like COPY --from=stain/jena-fuseki:4.0.0 /fuseki/. /fuseki
. However, none of them are working.
I have also not excluded anything with .dockerignore
2
Answers
You need to use a multi-stage build, see here: https://docs.docker.com/build/building/multi-stage/#name-your-build-stages
In your case, that would like something like:
fuseki is a run time directory. It is created when the container is instantiated. So, it is not present at the build time. Hence the error.
This is proved by the timestamp of the files in the screenshot below.