瀏覽代碼

improved hostConfig reload

Victor Vieux 11 年之前
父節點
當前提交
f482432a76
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      api.go
  2. 1 1
      container.go

+ 2 - 2
api.go

@@ -654,11 +654,11 @@ func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.R
 }
 
 func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
-	hostConfig := &HostConfig{}
-
+	var hostConfig *HostConfig
 	// allow a nil body for backwards compatibility
 	if r.Body != nil {
 		if matchesContentType(r.Header.Get("Content-Type"), "application/json") {
+			hostConfig = &HostConfig{}
 			if err := json.NewDecoder(r.Body).Decode(hostConfig); err != nil {
 				return err
 			}

+ 1 - 1
container.go

@@ -564,7 +564,7 @@ func (container *Container) Start(hostConfig *HostConfig) error {
 	container.State.Lock()
 	defer container.State.Unlock()
 
-	if len(hostConfig.Binds) == 0 && len(hostConfig.LxcConf) == 0 {
+	if hostConfig == nil { // in docker start of docker restart we want to reuse previous HostConfigFile
 		hostConfig, _ = container.ReadHostConfig()
 	}