diff --git a/api/server/container.go b/api/server/container.go index ccd97b6260..bc3143b6a5 100644 --- a/api/server/container.go +++ b/api/server/container.go @@ -399,13 +399,13 @@ func (s *Server) postContainersCreate(version version.Version, w http.ResponseWr } adjustCPUShares := version.LessThan("1.19") - containerID, warnings, err := s.daemon.ContainerCreate(name, config, hostConfig, adjustCPUShares) + container, warnings, err := s.daemon.ContainerCreate(name, config, hostConfig, adjustCPUShares) if err != nil { return err } return writeJSON(w, http.StatusCreated, &types.ContainerCreateResponse{ - ID: containerID, + ID: container.ID, Warnings: warnings, }) } diff --git a/builder/internals.go b/builder/internals.go index b951e59ea1..28f1b0ac7e 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -230,7 +230,7 @@ func (b *builder) runContextCommand(args []string, allowRemote bool, allowDecomp return nil } - container, _, err := b.Daemon.Create(b.Config, nil, "") + container, _, err := b.Daemon.ContainerCreate("", b.Config, nil, true) if err != nil { return err } @@ -613,7 +613,7 @@ func (b *builder) create() (*daemon.Container, error) { config := *b.Config // Create the container - c, warnings, err := b.Daemon.Create(b.Config, hostConfig, "") + c, warnings, err := b.Daemon.ContainerCreate("", b.Config, hostConfig, true) if err != nil { return nil, err } diff --git a/daemon/create.go b/daemon/create.go index 55e5e3f750..bd918774c3 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -11,15 +11,15 @@ import ( "github.com/opencontainers/runc/libcontainer/label" ) -func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hostConfig *runconfig.HostConfig, adjustCPUShares bool) (string, []string, error) { +func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hostConfig *runconfig.HostConfig, adjustCPUShares bool) (*Container, []string, error) { if config == nil { - return "", nil, fmt.Errorf("Config cannot be empty in order to create a container") + return nil, nil, fmt.Errorf("Config cannot be empty in order to create a container") } warnings, err := daemon.verifyContainerSettings(hostConfig, config) daemon.adaptContainerSettings(hostConfig, adjustCPUShares) if err != nil { - return "", warnings, err + return nil, warnings, err } container, buildWarnings, err := daemon.Create(config, hostConfig, name) @@ -29,14 +29,14 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos if tag == "" { tag = tags.DefaultTag } - return "", warnings, fmt.Errorf("No such image: %s (tag: %s)", config.Image, tag) + return nil, warnings, fmt.Errorf("No such image: %s (tag: %s)", config.Image, tag) } - return "", warnings, err + return nil, warnings, err } warnings = append(warnings, buildWarnings...) - return container.ID, warnings, nil + return container, warnings, nil } // Create creates a new container from the given configuration with a given name.