Skip to content

Commit

Permalink
Fix duplicate container names conflict
Browse files Browse the repository at this point in the history
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 <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Oct 26, 2015
1 parent 80439a4 commit aee5486
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions daemon/daemon.go
Expand Up @@ -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
}
Expand Down

0 comments on commit aee5486

Please sign in to comment.