I have a Dockerfile trying to package and deploy a web app to a container. The code of app fetches from git repository during Docker image building. Here\'s the Dockerfile s
Issue 1996 is not yet available, but you have the following workaround:
FROM foo
ARG CACHE_DATE=2016-01-01
RUN git clone ...
docker build --build-arg CACHE_DATE=$(date) ....
That would invalidate cache after the ARG CACHE_DATE line for every build.
Or:
ADD http://www.convert-unix-time.com/api?timestamp=now /tmp/bustcache
RUN git pull
That would also invalidate cache after this ADD line.
Similar idea:
Add
ARGcommand to your Dockerfile:# Dockerfile # add this and below command will run without cache ARG CACHEBUST=1When you need to rebuild with selected cache, run it with
--build-argoption$ docker build -t your-image --build-arg CACHEBUST=$(date +%s) .then only layer below
ARGcommand in Dockerfile will rebuild.