简体   繁体   中英

Why is the dockerfile not able to COPY?

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"]

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/

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

尝试使用您要复制的文件的相对路径谢谢

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM