Don't create a HostConfig accidentally if none was passed in
This commit is contained in:
1 parent
20c8b1eaf6
commit
50198a2159
1 file changed
+10
-7
@@ -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
|
||||
|
||||
Reference in new issue
Block a user