skip to Main Content

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


  1. 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:

    FROM stain/jena-fuseki:4.0.0 AS jena
    FROM python:3.8.15-slim
    COPY --from=jena /jena-fuseki /jena-fuseki
    
    Login or Signup to reply.
  2. 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.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search