From 50198a2159c46c1089f730539b08509387774e94 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 14 Oct 2015 10:43:31 +0100 Subject: [PATCH] Don't create a HostConfig accidentally if none was passed in --- proxy/start_container_interceptor.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/proxy/start_container_interceptor.go b/proxy/start_container_interceptor.go index 0d8963f4..89d0ebc4 100644 --- a/proxy/start_container_interceptor.go +++ b/proxy/start_container_interceptor.go @@ -12,22 +12,25 @@ func (i *startContainerInterceptor) InterceptRequest(r *http.Request) error { return err } + // If the client has sent some JSON which might be a HostConfig, add our + // parameters back into it, otherwise Docker will consider them overwritten if containerShouldAttach(container) && r.Header.Get("Content-Type") == "application/json" { hostConfig := map[string]interface{}{} if err := unmarshalRequestBody(r, &hostConfig); err != nil { return err } + if len(hostConfig) > 0 { + i.proxy.addWeaveWaitVolume(hostConfig) + if dnsDomain := i.proxy.getDNSDomain(); dnsDomain != "" { + if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil { + return err + } + } - i.proxy.addWeaveWaitVolume(hostConfig) - if dnsDomain := i.proxy.getDNSDomain(); dnsDomain != "" { - if err := i.proxy.setWeaveDNS(hostConfig, container.Config.Hostname, dnsDomain); err != nil { + if err := marshalRequestBody(r, hostConfig); err != nil { return err } } - - if err := marshalRequestBody(r, hostConfig); err != nil { - return err - } } i.proxy.createWait(r, container.ID) return nil