Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When will 'docker build' rebuild a layer?

I used following command to clone a repo in order to use it in my docker container:

RUN git clone ssh://my.repo.com/repo

The problem is, that when building the docker container, docker does not clone the repo again, but used the cached one.

I quick-fixed it by using docker build --no-cache, but that rebuilds all the layers.

How can I rebuild a selected layer only?

like image 763
arm Avatar asked Apr 20 '26 21:04

arm


1 Answers

In the Dockerfile:

ARG CACHEBUST=1
RUN git clone https://github.com/octocat/Hello-World.git

On the command line:

docker build -t your-image --build-arg CACHEBUST=$(date +%s)

source: https://github.com/moby/moby/issues/1996#issuecomment-185872769

like image 178
arm Avatar answered Apr 22 '26 13:04

arm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!