From d990e2b322a3af318d451584e7a469962bba8176 Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Tue, 19 Jun 2018 17:07:41 +0200 Subject: [PATCH] Improve duplicate name error message on container create Signed-off-by: Marco Vedovati Make the error message more informative by specifying the duplicate name and the existing container ID. --- containers.go | 4 +++- containers_ffjson.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/containers.go b/containers.go index ec54a502e9..ebc1e99a0f 100644 --- a/containers.go +++ b/containers.go @@ -2,6 +2,7 @@ package storage import ( "encoding/json" + "fmt" "io/ioutil" "os" "path/filepath" @@ -278,7 +279,8 @@ func (r *containerStore) Create(id string, names []string, image, layer, metadat names = dedupeNames(names) for _, name := range names { if _, nameInUse := r.byname[name]; nameInUse { - return nil, ErrDuplicateName + return nil, errors.Wrapf(ErrDuplicateName, + fmt.Sprintf("the container name \"%s\" is already in use by \"%s\". You have to remove that container to be able to reuse that name.", name, r.byname[name].ID)) } } if err == nil { diff --git a/containers_ffjson.go b/containers_ffjson.go index aef6becfe0..6e83808d4f 100644 --- a/containers_ffjson.go +++ b/containers_ffjson.go @@ -1,5 +1,6 @@ // Code generated by ffjson . DO NOT EDIT. // source: containers.go +// package storage