Skip to content

Commit

Permalink
Improve duplicate name error message on container create
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Vedovati <[email protected]>

Make the error message more informative by specifying the duplicate name
and the existing container ID.
  • Loading branch information
marcov committed Jun 19, 2018
1 parent 88d8042 commit d990e2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package storage

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions containers_ffjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d990e2b

Please sign in to comment.