diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 36 | ||||
-rw-r--r-- | libpod/image_inspect.go | 2 |
2 files changed, 35 insertions, 3 deletions
diff --git a/libpod/container.go b/libpod/container.go index 15ad1f49a..dc22c9c61 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -890,6 +890,10 @@ func (c *Container) Export(path string) error { return err } + return c.export(path) +} + +func (c *Container) export(path string) error { mountPoint := c.state.Mountpoint if !c.state.Mounted { mount, err := c.runtime.store.Mount(c.ID(), c.config.MountLabel) @@ -965,8 +969,36 @@ func (c *Container) Inspect(size bool) (*ContainerInspectData, error) { // Commit commits the changes between a container and its image, creating a new // image -func (c *Container) Commit() (*storage.Image, error) { - return nil, ErrNotImplemented +func (c *Container) Commit(pause bool, options CopyOptions) error { + c.lock.Lock() + defer c.lock.Unlock() + + if err := c.syncContainer(); err != nil { + return err + } + + if c.state.State == ContainerStateRunning && pause { + if err := c.runtime.ociRuntime.pauseContainer(c); err != nil { + return errors.Wrapf(err, "error pausing container %q", c.ID()) + } + defer func() { + if err := c.runtime.ociRuntime.unpauseContainer(c); err != nil { + logrus.Errorf("error unpausing container %q: %v", c.ID(), err) + } + }() + } + + tempFile, err := ioutil.TempFile(c.runtime.config.TmpDir, "podman-commit") + if err != nil { + return errors.Wrapf(err, "error creating temp file") + } + defer os.Remove(tempFile.Name()) + defer tempFile.Close() + + if err := c.export(tempFile.Name()); err != nil { + return err + } + return c.runtime.ImportImage(tempFile.Name(), options) } // Wait blocks on a container to exit and returns its exit code diff --git a/libpod/image_inspect.go b/libpod/image_inspect.go index a08665434..3d904e64b 100644 --- a/libpod/image_inspect.go +++ b/libpod/image_inspect.go @@ -47,7 +47,7 @@ func getImageData(img storage.Image, imgRef types.Image, size int64, driver *dri RepoDigests: repoDigests, Comment: ociv1Img.History[0].Comment, Created: ociv1Img.Created, - Author: ociv1Img.History[0].Author, + Author: ociv1Img.Author, Architecture: ociv1Img.Architecture, Os: ociv1Img.OS, Config: &ociv1Img.Config, |