skip to Main Content

I’m creating simple React app with Docker image but for some reason I keep getting the following error:

COPY failed: file not found in build context or excluded by .dockerignore: stat build: file does not exist

Here’s the dockerfile:

FROM /httpd:2.4.38

ENV SRVROOT=/usr/local/apache2

ENV myapp=$SRVROOT/myapp

COPY /app/build $myapp
COPY /Docker/run.sh $SRVROOT
COPY /Docker/httpd.conf $SRVROOT/conf/

RUN chmod 755 $SRVROOT/run.sh

CMD ["/usr/local/apache2/run.sh"]

3

Answers


  1. The --from flag is used for multi-stage builds. It does not look like this is your case. Try removing the --from flag from your dockerfile

    Login or Signup to reply.
  2. The first argument to COPY is the location of the file on the host machine. The leading slash means you’re trying to copy from /app and /Dockerfile (at the root of your computer), which is outside Docker context. Those files should be relative to the current directory:

    COPY ./app/build $myapp
    COPY ./Docker/run.sh $SRVROOT
    COPY ./Docker/httpd.conf $SRVROOT/conf/
    
    Login or Signup to reply.
  3. Try using their relative path for the files you want to copy
    Thanks

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