From 231e07ded4debc69422696cacc069a47a77e3175 Mon Sep 17 00:00:00 2001 From: Eric Windisch Date: Wed, 6 Aug 2014 11:54:13 -0400 Subject: [PATCH] Container name lookups to prefer IDs over names Lookups of container names should prefer the ID over names assigned to containers by users. Signed-off-by: Eric Windisch --- daemon/daemon.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 3da5422c6e..18b54e9f1b 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -138,16 +138,13 @@ func (daemon *Daemon) Install(eng *engine.Engine) error { // Get looks for a container by the specified ID or name, and returns it. // If the container is not found, or if an error occurs, nil is returned. func (daemon *Daemon) Get(name string) *Container { + if id, err := daemon.idIndex.Get(name); err == nil { + return daemon.containers.Get(id) + } if c, _ := daemon.GetByName(name); c != nil { return c } - - id, err := daemon.idIndex.Get(name) - if err != nil { - return nil - } - - return daemon.containers.Get(id) + return nil } // Exists returns a true if a container of the specified ID or name exists,