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