Browse Source

* 'docker commit' inherits parent layer's run configuration by default

Solomon Hykes 12 năm trước cách đây
mục cha
commit
ad86dde10c
2 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 2 1
      commands.go
  2. 5 0
      graph.go

+ 2 - 1
commands.go

@@ -736,8 +736,9 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
 		return nil
 	}
 
-	config := &Config{}
+	var config *Config
 	if *flConfig != "" {
+		config = &Config{}
 		if err := json.Unmarshal([]byte(*flConfig), config); err != nil {
 			return err
 		}

+ 5 - 0
graph.go

@@ -97,6 +97,11 @@ func (graph *Graph) Create(layerData Archive, container *Container, comment, aut
 		img.Parent = container.Image
 		img.Container = container.Id
 		img.ContainerConfig = *container.Config
+		if config == nil {
+			if parentImage, err := graph.Get(container.Image); err == nil && parentImage != nil {
+				img.Config = parentImage.Config
+			}
+		}
 	}
 	if err := graph.Register(layerData, img); err != nil {
 		return nil, err