From aee54863741fc3f012c423d1a445d1a6b687966a Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 26 Oct 2015 16:57:50 -0700 Subject: [PATCH] Fix duplicate container names conflict While creating multiple containers the second container could remove the first one from graph and not produce an error. Fixes #15995 Signed-off-by: Tonis Tiigi --- daemon/daemon.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 83b15a302e..5159d4f7da 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -407,20 +407,12 @@ func (daemon *Daemon) reserveName(id, name string) (string, error) { conflictingContainer, err := daemon.GetByName(name) if err != nil { - if strings.Contains(err.Error(), "Could not find entity") { - return "", err - } - - // Remove name and continue starting the container - if err := daemon.containerGraphDB.Delete(name); err != nil { - return "", err - } - } else { - nameAsKnownByUser := strings.TrimPrefix(name, "/") - return "", fmt.Errorf( - "Conflict. The name %q is already in use by container %s. You have to remove (or rename) that container to be able to reuse that name.", nameAsKnownByUser, - stringid.TruncateID(conflictingContainer.ID)) + return "", err } + return "", fmt.Errorf( + "Conflict. The name %q is already in use by container %s. You have to remove (or rename) that container to be able to reuse that name.", strings.TrimPrefix(name, "/"), + stringid.TruncateID(conflictingContainer.ID)) + } return name, nil }