Decouple daemon and container to mount and unmount filesystems.

Side effects:
- Decouple daemon and container to start containers.
- Decouple daemon and container to copy files.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 3a497650464b40191bd2cde348e676acf4efe270
Component: engine
This commit is contained in:
David Calavera
2015-11-04 12:27:47 -05:00
parent 57930f801e
commit b52340d649
17 changed files with 188 additions and 176 deletions
@@ -399,8 +399,8 @@ func run(b *Builder, args []string, attributes map[string]bool, original string)
// Ensure that we keep the container mounted until the commit
// to avoid unmounting and then mounting directly again
c.Mount()
defer c.Unmount()
b.docker.Mount(c)
defer b.docker.Unmount(c)
err = b.run(c)
if err != nil {
@@ -67,10 +67,10 @@ func (b *Builder) commit(id string, autoCmd *stringutils.StrSlice, comment strin
}
id = container.ID
if err := container.Mount(); err != nil {
if err := b.docker.Mount(container); err != nil {
return err
}
defer container.Unmount()
defer b.docker.Unmount(container)
}
container, err := b.docker.Container(id)
@@ -201,7 +201,7 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowLocalD
if err != nil {
return err
}
defer container.Unmount()
defer b.docker.Unmount(container)
b.tmpContainers[container.ID] = struct{}{}
comment := fmt.Sprintf("%s %s in %s", cmdName, origPaths, dest)
@@ -524,7 +524,7 @@ func (b *Builder) create() (*daemon.Container, error) {
if err != nil {
return nil, err
}
defer c.Unmount()
defer b.docker.Unmount(c)
for _, warning := range warnings {
fmt.Fprintf(b.Stdout, " ---> [Warning] %s\n", warning)
}
@@ -549,7 +549,7 @@ func (b *Builder) run(c *daemon.Container) error {
}
//start the container
if err := c.Start(); err != nil {
if err := b.docker.Start(c); err != nil {
return err
}