我的Git repo在我的Docker映像中没有改变,即使使用新标签重建。
我在一个构建中运行git clone
,它工作正常:
# dockerfile
FROM python:3.8
ENV PYTHONUNBUFFERED 1
# To fix GPG key error when running apt-get update
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/my_git_username/repo_name.git
WORKDIR /repo_name
我构建:
docker build -t username/exam:0.1
然后,我将一个名为tmp.txt
的文件推送到该存储库,并运行一个新的构建:
docker build -t username/exam:0.2
我以为这个命令会失败,因为我把repo改成了private,但是它成功了,所以我进入容器内部,检查了里面的内容:
一个三个三个一个
并且我确认tmp.txt
不存在(这是repo的前一个状态)。
这是我所期望的:
=> ERROR [6/7] RUN git clone https://github.com/my_git_username/repo_name.git 1.1s
------
> > [6/7] RUN git clone https://github.com/my_git_username/repo_name.git:
> #10 0.632 Cloning into 'repo_name'...
> #10 1.007 fatal: could not read Username for 'https://github.com': No such device or address
> ------
> executor failed running [/bin/sh -c git clone https://github.com/my_git_username/repo_name.git]: exit code: 128
我需要的帮助:
- 为什么第二张图片中的git repo在上一次提交时?
- 我怎样才能在不修改Dockerfile的情况下自动带来最新的修改?
1条答案
按热度按时间af7jpaap1#
使用
docker build --no-cache
.Docker caches layers,很可能缓存git clone
层(步骤),因为命令没有改变,前面层的校验和也没有改变。例如:
docker build --no-cache -t username/exam:0.3 .
。