Reputation: 63
How can I make sure docker build will sync docker cache with docker registry?
Imagine this scenario:
1 - I create a docker image on my laptop for weblogic called:
my-local-registry:5000/weblogic:12.2.1.3
2 - Then I push it to our local docker registry:
docker push my-local-registry:5000/weblogic:12.2.1.3
3 - in one of our servers (for example host-1), I have a docker file where it uses this weblogic image to build an application image, something like this:
FROM my-local-registry:5000/weblogic:12.2.1.3
USER weblogic
WORKDIR /u01/scripts
RUN deploy_application.sh
.
.
.
4 - I create application image:
docker build -t my_application .
5 - On host-1, I execute docker images command and I see 2 images. One is weblogic one which is pulled from local registry and the other one is application image.
7 - Now, I update weblogic image on my laptop (for example, apply new security patch) and push it again:
docker push my-local-registry:5000/weblogic:12.2.1.3
8 - On host-1, I re-create application image. As it already has weblogic image in docker cache, it's not going to take the updated one.
How can I force docker to check if any existing image in docker cache is synced with local registry when it comes to FROM command?
(When I run docker pull my-local-registry:5000/weblogic:12.2.1.3
, it updates docker cache, but I don't want to do this every time!)
Thanks a lot in advance.
Upvotes: 1
Views: 802
Reputation: 63
I found the solution. What I needed was --pull
docker build --pull ...
It will compare the docker cache with docker registry and pull the updated layers from docker registry if they don't exist in docker cache.
Upvotes: 0