traefik/integration/vendor/github.com/libkermit/docker/start.go
2017-03-09 13:13:03 +01:00

28 lines
855 B
Go

package docker
import (
"golang.org/x/net/context"
"github.com/docker/engine-api/types"
)
// Start lets you create and start a container with the specified image, and
// default configuration.
func (p *Project) Start(image string) (types.ContainerJSON, error) {
return p.StartWithConfig(image, ContainerConfig{})
}
// StartWithConfig lets you create and start a container with the specified
// image, and some custom simple configuration.
func (p *Project) StartWithConfig(image string, containerConfig ContainerConfig) (types.ContainerJSON, error) {
container, err := p.CreateWithConfig(image, containerConfig)
if err != nil {
return types.ContainerJSON{}, err
}
if err := p.Client.ContainerStart(context.Background(), container.ID, types.ContainerStartOptions{}); err != nil {
return container, err
}
return p.Inspect(container.ID)
}