mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix issue #3375 - Return most recent image from the cache
ImageGetCached searches for an image from the cache. Instead of returning the first image it finds, it should return the most recently created image. When a build with --no-cache then adds a new image with the same parameters, it is used instead of the old, existing image. Docker-DCO-1.0-Signed-off-by: Sjoerd Langkemper <sjoerd@byte.nl> (github: Sjord)
This commit is contained in:
parent
10b794b332
commit
46c8b11f24
1 changed files with 5 additions and 2 deletions
|
@ -1705,16 +1705,19 @@ func (srv *Server) ImageGetCached(imgID string, config *Config) (*Image, error)
|
|||
}
|
||||
|
||||
// Loop on the children of the given image and check the config
|
||||
var match *Image
|
||||
for elem := range imageMap[imgID] {
|
||||
img, err := srv.runtime.graph.Get(elem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if CompareConfig(&img.ContainerConfig, config) {
|
||||
return img, nil
|
||||
if match == nil || match.Created.Before(img.Created) {
|
||||
match = img
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
return match, nil
|
||||
}
|
||||
|
||||
func (srv *Server) RegisterLinks(container *Container, hostConfig *HostConfig) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue