我正在Dockerfile上进行docker构建,它在以下步骤中失败
COPY /tmp/mvnrepository.tgz /opt/mvnrepository.tgz
我尝试过用docker build-f Dockerfile指定文件名,但还是出现了错误。我试着从父目录构建它,其中包含dockerfile的路径和如下所示的文件名,但我仍然得到错误
cd /home/parentdirectory
docker build . -f /childdirectory/Dockerfile
问题是/home/parentdirectory
是您的docker构建上下文,而/tmp/mvnrepository.tgz
不在其中。将文件复制到/home/parentdirectory
中,然后在Dockerfile中相应地更改COPY
的第一个参数。
COPY /home/parentdirectory/mvnrepository.tgz /opt/mvnrepository.tgz