Merge pull request #1291 from dotcloud/ensure_mount_commit
*Builder: Allow the commit of a non-started container
diff --git a/builder.go b/builder.go
index ab07233..420370b 100644
--- a/builder.go
+++ b/builder.go
@@ -124,6 +124,10 @@
func (builder *Builder) Commit(container *Container, repository, tag, comment, author string, config *Config) (*Image, error) {
// FIXME: freeze the container before copying it to avoid data corruption?
// FIXME: this shouldn't be in commands.
+ if err := container.EnsureMounted(); err != nil {
+ return nil, err
+ }
+
rwTar, err := container.ExportRw()
if err != nil {
return nil, err
diff --git a/server_test.go b/server_test.go
index b6b21cc..57e2376 100644
--- a/server_test.go
+++ b/server_test.go
@@ -91,6 +91,27 @@
}
+func TestCommit(t *testing.T) {
+ runtime := mkRuntime(t)
+ defer nuke(runtime)
+
+ srv := &Server{runtime: runtime}
+
+ config, _, _, err := ParseRun([]string{GetTestImage(runtime).ID, "/bin/cat"}, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ id, err := srv.ContainerCreate(config)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if _, err := srv.ContainerCommit(id, "testrepo", "testtag", "", "", config); err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestCreateStartRestartStopStartKillRm(t *testing.T) {
runtime := mkRuntime(t)
defer nuke(runtime)