我正在使用以下Dockerfile内容:
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install git -y
RUN git clone https://code.qt.io/qt/qt5.git /cloned-qt
RUN cd /cloned-qt/
RUN git checkout 5.11
RUN git pull
当我运行我的构建镜像命令时:
sudo docker build -t qt5.11-auto:v1 .
我收到了这个错误信息:
Sending build context to Docker daemon 4.608kB
Step 1/10 : FROM ubuntu:18.04
---> ea4c82dcd15a
Step 2/10 : RUN apt-get update
---> Using cache
---> 60e7c61ea78c
Step 3/10 : RUN apt-get install git -y
---> Using cache
---> 50a4def0607e
Step 4/10 : RUN git clone https://code.qt.io/qt/qt5.git /cloned-qt
---> Using cache
---> 97fb8ab6dc15
Step 5/10 : RUN cd /cloned-qt/
---> Running in 9be03fba40fa
Removing intermediate container 9be03fba40fa
---> 130bc457eb66
Step 6/10 : RUN git checkout 5.11
---> Running in 35de823fdf9c
fatal: not a git repository (or any of the parent directories): .git
在这个失败的步骤之后,当我运行容器并执行相同的命令时,我成功地运行了它们。似乎Docker构建无法运行“git checkout”命令,但在容器内运行时却可以正常工作的原因是什么?
WORKDIR
替代cd
怎么样? - evolutionxbox