mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use name instead of container in Commit
It will make daemon interface separation easier later. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
b52bedbd48
commit
38e34cf6da
5 changed files with 35 additions and 34 deletions
|
@ -1,6 +1,9 @@
|
|||
package daemon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/docker/image"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
|
@ -15,17 +18,35 @@ type ContainerCommitConfig struct {
|
|||
Tag string
|
||||
Author string
|
||||
Comment string
|
||||
Config *runconfig.Config
|
||||
// merge container config into commit config before commit
|
||||
MergeConfigs bool
|
||||
Config *runconfig.Config
|
||||
}
|
||||
|
||||
// Commit creates a new filesystem image from the current state of a container.
|
||||
// The image can optionally be tagged into a repository.
|
||||
func (daemon *Daemon) Commit(container *Container, c *ContainerCommitConfig) (*image.Image, error) {
|
||||
func (daemon *Daemon) Commit(name string, c *ContainerCommitConfig) (*image.Image, error) {
|
||||
container, err := daemon.Get(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// It is not possible to commit a running container on Windows
|
||||
if runtime.GOOS == "windows" && container.IsRunning() {
|
||||
return nil, fmt.Errorf("Windows does not support commit of a running container")
|
||||
}
|
||||
|
||||
if c.Pause && !container.isPaused() {
|
||||
daemon.containerPause(container)
|
||||
defer daemon.containerUnpause(container)
|
||||
}
|
||||
|
||||
if c.MergeConfigs {
|
||||
if err := runconfig.Merge(c.Config, container.Config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
rwTar, err := daemon.exportContainerRw(container)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue