Browse code

'docker commit -m': optional commit message

Solomon Hykes authored on 2013/03/24 11:16:42
Showing 2 changed files
... ...
@@ -630,6 +630,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
630 630
 	cmd := rcli.Subcmd(stdout,
631 631
 		"commit", "[OPTIONS] CONTAINER [REPOSITORY [TAG]]",
632 632
 		"Create a new image from a container's changes")
633
+	fl_comment := cmd.String("m", "", "Commit message")
633 634
 	if err := cmd.Parse(args); err != nil {
634 635
 		return nil
635 636
 	}
... ...
@@ -638,7 +639,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
638 638
 		cmd.Usage()
639 639
 		return nil
640 640
 	}
641
-	img, err := srv.runtime.Commit(containerName, repository, tag)
641
+	img, err := srv.runtime.Commit(containerName, repository, tag, *fl_comment)
642 642
 	if err != nil {
643 643
 		return err
644 644
 	}
... ...
@@ -181,7 +181,7 @@ func (runtime *Runtime) Destroy(container *Container) error {
181 181
 
182 182
 // Commit creates a new filesystem image from the current state of a container.
183 183
 // The image can optionally be tagged into a repository
184
-func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
184
+func (runtime *Runtime) Commit(id, repository, tag, comment string) (*Image, error) {
185 185
 	container := runtime.Get(id)
186 186
 	if container == nil {
187 187
 		return nil, fmt.Errorf("No such container: %s", id)
... ...
@@ -193,7 +193,7 @@ func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
193 193
 		return nil, err
194 194
 	}
195 195
 	// Create a new image from the container's base layers + a new layer from container changes
196
-	img, err := runtime.graph.Create(rwTar, container, "")
196
+	img, err := runtime.graph.Create(rwTar, container, comment)
197 197
 	if err != nil {
198 198
 		return nil, err
199 199
 	}