From ace6c01b00113a8cfa80f06de7f93a01f94f6252 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Mon, 19 Oct 2015 11:33:12 +0100 Subject: [PATCH] Review feedback --- proxy/proxy.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index adc784c4..3997426e 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -116,16 +116,17 @@ func NewProxy(c Config) (*Proxy, error) { func (proxy *Proxy) AttachExistingContainers() { containers, _ := proxy.client.ListContainers(docker.ListContainersOptions{}) - for _, apiContainer := range containers { - container, err := proxy.client.InspectContainer(apiContainer.ID) + for _, c := range containers { + container, err := proxy.client.InspectContainer(c.ID) if err != nil { - Log.Warningf("Error inspecting container %s: %v", apiContainer.ID, err) + if _, ok := err.(*docker.NoSuchContainer); !ok { + Log.Warningf("unable to attach existing container %s since inspecting it failed: %v", c.ID, err) + } continue } - if containerShouldAttach(container) { + if containerShouldAttach(container) && (container.State.Running || container.State.Paused) { proxy.attach(container, false) } - proxy.notifyWaiters(container.ID) } } @@ -296,7 +297,9 @@ func (proxy *Proxy) listen(protoAndAddr string) (net.Listener, string, error) { func (proxy *Proxy) ContainerStarted(ident string) { container, err := proxy.client.InspectContainer(ident) if err != nil { - Log.Warningf("Error inspecting container %s: %v", ident, err) + if _, ok := err.(*docker.NoSuchContainer); !ok { + Log.Warningf("unable to attach new container %s since inspecting it failed: %v", ident, err) + } return } // If this was a container we modified the entrypoint for, attach it to the network