diff --git a/AUTHORS b/AUTHORS index 214c87ce259efa3c1f283f0dd0c6c64c31fa90c4..60533c1cc2c41b9332c2c63ffd6d7a18c379a805 100644 --- a/AUTHORS +++ b/AUTHORS @@ -44,6 +44,7 @@ Daniel Nordberg Daniel Robinson Daniel Von Fange Daniel YC Lin +Darren Coxall David Calavera David Sissitka Deni Bertovic diff --git a/integration/runtime_test.go b/integration/runtime_test.go index fb928d8160b3e74737d3f3db4be583c6b128c79e..320a3645b05797aebddf21664ff0fd6500089cb7 100644 --- a/integration/runtime_test.go +++ b/integration/runtime_test.go @@ -231,6 +231,18 @@ func TestRuntimeCreate(t *testing.T) { t.Errorf("Exists() returned false for a newly created container") } + // Test that conflict error displays correct details + testContainer, _, _ := runtime.Create( + &docker.Config{ + Image: GetTestImage(runtime).ID, + Cmd: []string{"ls", "-al"}, + }, + "conflictname", + ) + if _, _, err := runtime.Create(&docker.Config{Image: GetTestImage(runtime).ID, Cmd: []string{"ls", "-al"}}, testContainer.Name); err == nil || !strings.Contains(err.Error(), utils.TruncateID(testContainer.ID)) { + t.Fatalf("Name conflict error doesn't include the correct short id. Message was: %s", err.Error()) + } + // Make sure create with bad parameters returns an error if _, _, err = runtime.Create(&docker.Config{Image: GetTestImage(runtime).ID}, ""); err == nil { t.Fatal("Builder.Create should throw an error when Cmd is missing") diff --git a/runtime.go b/runtime.go index 4559164e280071f43a0058c686637e6cd25ea133..f8c15767d75732ffe802dd52b25d1b96444f807b 100644 --- a/runtime.go +++ b/runtime.go @@ -402,7 +402,8 @@ func (runtime *Runtime) Create(config *Config, name string) (*Container, []strin // Set the enitity in the graph using the default name specified if _, err := runtime.containerGraph.Set(name, id); err != nil { if strings.HasSuffix(err.Error(), "name are not unique") { - return nil, nil, fmt.Errorf("Conflict, %s already exists.", name) + conflictingContainer, _ := runtime.GetByName(name) + return nil, nil, fmt.Errorf("Conflict, The name %s is already assigned to %s. You have to delete (or rename) that container to be able to assign %s to a container again.", name, utils.TruncateID(conflictingContainer.ID), name) } return nil, nil, err }