From f17410da5e4b5fa0e0dd2614f9b6e00dbcf66da6 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Thu, 4 Sep 2014 19:43:28 +0400 Subject: [PATCH] Fix race between dispatchers.run and toDisk Signed-off-by: Alexandr Morozov --- builder/internals.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builder/internals.go b/builder/internals.go index 62fff0701b..b7c2f97e10 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -68,15 +68,10 @@ func (b *Builder) commit(id string, autoCmd []string, comment string) error { return nil } - container, warnings, err := b.Daemon.Create(b.Config, "") + container, err := b.create() if err != nil { return err } - for _, warning := range warnings { - fmt.Fprintf(b.OutStream, " ---> [Warning] %s\n", warning) - } - b.TmpContainers[container.ID] = struct{}{} - fmt.Fprintf(b.OutStream, " ---> Running in %s\n", utils.TruncateID(container.ID)) id = container.ID if err := container.Mount(); err != nil { @@ -373,18 +368,23 @@ func (b *Builder) create() (*daemon.Container, error) { } b.Config.Image = b.image + config := *b.Config + // Create the container - c, _, err := b.Daemon.Create(b.Config, "") + c, warnings, err := b.Daemon.Create(b.Config, "") if err != nil { return nil, err } + for _, warning := range warnings { + fmt.Fprintf(b.OutStream, " ---> [Warning] %s\n", warning) + } b.TmpContainers[c.ID] = struct{}{} fmt.Fprintf(b.OutStream, " ---> Running in %s\n", utils.TruncateID(c.ID)) // override the entry point that may have been picked up from the base image - c.Path = b.Config.Cmd[0] - c.Args = b.Config.Cmd[1:] + c.Path = config.Cmd[0] + c.Args = config.Cmd[1:] return c, nil }