diff --git a/api/server/server.go b/api/server/server.go index 87b40d21c8..502f1ae9e1 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -698,6 +698,7 @@ func getImagesGet(eng *engine.Engine, version version.Version, w http.ResponseWr func postImagesLoad(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error { job := eng.Job("load") job.Stdin.Add(r.Body) + job.Stdout.Add(w) return job.Run() } diff --git a/graph/load.go b/graph/load.go index a3a75bce4d..ace222e3fe 100644 --- a/graph/load.go +++ b/graph/load.go @@ -68,7 +68,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) error { for imageName, tagMap := range repositories { for tag, address := range tagMap { - if err := s.Set(imageName, tag, address, true); err != nil { + if err := s.SetLoad(imageName, tag, address, true, job.Stdout); err != nil { return err } } diff --git a/graph/tags.go b/graph/tags.go index 4ed63d9597..b6a7987ff8 100644 --- a/graph/tags.go +++ b/graph/tags.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "io" "io/ioutil" "os" "path/filepath" @@ -221,6 +222,10 @@ func (store *TagStore) Delete(repoName, ref string) (bool, error) { } func (store *TagStore) Set(repoName, tag, imageName string, force bool) error { + return store.SetLoad(repoName, tag, imageName, force, nil) +} + +func (store *TagStore) SetLoad(repoName, tag, imageName string, force bool, out io.Writer) error { img, err := store.LookupImage(imageName) store.Lock() defer store.Unlock() @@ -243,8 +248,17 @@ func (store *TagStore) Set(repoName, tag, imageName string, force bool) error { repoName = registry.NormalizeLocalName(repoName) if r, exists := store.Repositories[repoName]; exists { repo = r - if old, exists := store.Repositories[repoName][tag]; exists && !force { - return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old) + if old, exists := store.Repositories[repoName][tag]; exists { + + if !force { + return fmt.Errorf("Conflict: Tag %s is already set to image %s, if you want to replace it, please use -f option", tag, old) + } + + if old != img.ID && out != nil { + + fmt.Fprintf(out, "The image %s:%s already exists, renaming the old one with ID %s to empty string\n", repoName, tag, old[:12]) + + } } } else { repo = make(map[string]string)