Bläddra i källkod

'docker commit -m': optional commit message

Solomon Hykes 12 år sedan
förälder
incheckning
0d46ddf7b4
2 ändrade filer med 4 tillägg och 3 borttagningar
  1. 2 1
      commands.go
  2. 2 2
      runtime.go

+ 2 - 1
commands.go

@@ -630,6 +630,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
 	cmd := rcli.Subcmd(stdout,
 		"commit", "[OPTIONS] CONTAINER [REPOSITORY [TAG]]",
 		"Create a new image from a container's changes")
+	fl_comment := cmd.String("m", "", "Commit message")
 	if err := cmd.Parse(args); err != nil {
 		return nil
 	}
@@ -638,7 +639,7 @@ func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri
 		cmd.Usage()
 		return nil
 	}
-	img, err := srv.runtime.Commit(containerName, repository, tag)
+	img, err := srv.runtime.Commit(containerName, repository, tag, *fl_comment)
 	if err != nil {
 		return err
 	}

+ 2 - 2
runtime.go

@@ -181,7 +181,7 @@ func (runtime *Runtime) Destroy(container *Container) error {
 
 // Commit creates a new filesystem image from the current state of a container.
 // The image can optionally be tagged into a repository
-func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
+func (runtime *Runtime) Commit(id, repository, tag, comment string) (*Image, error) {
 	container := runtime.Get(id)
 	if container == nil {
 		return nil, fmt.Errorf("No such container: %s", id)
@@ -193,7 +193,7 @@ func (runtime *Runtime) Commit(id, repository, tag string) (*Image, error) {
 		return nil, err
 	}
 	// Create a new image from the container's base layers + a new layer from container changes
-	img, err := runtime.graph.Create(rwTar, container, "")
+	img, err := runtime.graph.Create(rwTar, container, comment)
 	if err != nil {
 		return nil, err
 	}