When does the Docker Image Cache invalidate?

My Google Foo may not be strong enough, but I can’t find a specific list about when Docker images in the cache are invalid. In particular, I'm interested in at least these scenarios:

  • Invalidity due to mtime changes vs checksum changes . What applies when? Can it deal with different source paths (e.g. repository clones in different directories)?
  • Invalidity due to updated base images . At this point in the update (security), for example. Does Debian attack me?
  • Are there explicit APIs that the continuous integration tool can use to tell Docker that cached images can be reused and which cannot (e.g. due to wget foo.com/latest.gz)?
+4
source share
1 answer

Like Docker 1.8, Docker no longer uses mtimeto cancel the cache (this changed in this request to pull # 12031 ).

When creating an image

  • For local content ( ADD myfiles /somewhere/ COPY myfiles /somewhere), docker uses checksum changes to invalidate cache
  • Remote content ( ADD http://example.com/foobar /somewhere) is always loaded, but the build cache is invalid based on checksum changes.
  • RUN (, wget foo.com/latest.gz) , ; . , , URL (wget http://example.com/package-major.minor.patch.gz)

Docker 1.9 , , Docker, t Docker, , .

FROM foobar
ARG MAJOR=1
ARG MINOR=0
ARG PATCH=0
ADD http://example.com/package-$MAJOR.$MINOR.$PATCH.gz /

http://example.com/package-1.0.0.gz, "major", "minor" "patch" build-time ;

docker build --build-arg MINOR=2 .                                           Sat Jan 16 13:22:40 2016
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu
 ---> 1c9b046c2850
Step 2 : ARG MAJOR=1
 ---> Using cache
 ---> a149d88772ba
Step 3 : ARG MINOR=0
 ---> Using cache
 ---> e3dae0189ffd
Step 4 : ARG PATCH=0
 ---> Using cache
 ---> 678d7ae33054
Step 5 : ADD http://example.com/package-$MAJOR.$MINOR.$PATCH.gz /
Get http://example.com/package-1.2.0.gz: dial tcp 127.0.0.1:80: getsockopt: connection refused

.

(), . Debian ?

Docker , . , docker pull yourbaseimage , - , .

Docker , , , .

+6

Source: https://habr.com/ru/post/1624464/


All Articles