Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorContainerExitedWithNonZeroCode = errors.New("exited with non 0 code") ErrorContainerDead = errors.New("container died") ErrorContainerStartTimeout = errors.New("timed out waiting for the container to start") )
View Source
var ( ErrorClientNotSet = errors.New("client not set") ErrorEmptyCommand = errors.New("container command cannot be empty") )
View Source
var ErrorImageDoesNotExist = errors.New("no such image")
ErrorImageDoesNotExist returned when inspecting an image that does not exist on the system.
Functions ¶
Types ¶
type Container ¶
type Container interface {
HasIOStream
// ID the id of the container.
ID() string
// Create the container, call Start to start it.
Create(ctx context.Context) error
// Start the container.
Start(ctx context.Context, timeout time.Duration) error
// Stop sends SIGINT to the container.
Stop(ctx context.Context) error
// Kill sends SIGKILL to the container.
Kill(ctx context.Context) error
// Wait for the container to stop running, see dockercontainer.WaitCondition.
Wait(ctx context.Context) error
// Remove the container.
Remove(ctx context.Context) error
// Exec execute a Command in the running container.
Exec(ctx context.Context, cfg ExecConfig) (Exec, error)
// AttachIO attach the I/O streams from the running command of the container to the Wrapper streams.
AttachIO(ctx context.Context) (IOStreamer, error)
// Inspect the container.
Inspect(ctx context.Context) (types.ContainerJSON, error)
// Resize the container
Resize(ctx context.Context, width uint, height uint)
}
Container represents a docker container.
func FindContainerByName ¶
FindContainerByName tries to find an existing container with the same name in the docker daemon.
func NewContainer ¶
func NewContainer(cfg ContainerConfig) (Container, error)
type ContainerConfig ¶
type ContainerConfig struct {
Image string // Image Required
Enviroment map[string]string // Enviroment container's enviroment name:value
Labels map[string]string // Labels container's labels name:value
Directories map[string]string // Directories to mount to container src:target
WorkingDir string // WorkingDir the work directory of the container. Required
Name string // Name is the container name, defaults to randomly generated
IOStream IOStream // IOStream the input/output streams
Command Command // Command the command to start the container with
AutoRemove bool // AutoRemove automatically remove the container when it exits
TTY bool // TTY enable tty on the container
}
ContainerConfig contains the configuration data about a container.
type ContainerStatus ¶
type ContainerStatus string
const ( ContainerStatusCreated ContainerStatus = "created" ContainerStatusRunning ContainerStatus = "running" ContainerStatusPaused ContainerStatus = "paused" ContainerStatusRestarting ContainerStatus = "restarting" ContainerStatusRemoving ContainerStatus = "removing" ContainerStatusExited ContainerStatus = "exited" ContainerStatusDead ContainerStatus = "dead" )
type Exec ¶
type Exec interface {
HasIOStream
// ID the Exec id.
ID() string
// Start the Exec.
Start(ctx context.Context) error
// AttachIO attach the I/O streams from the running to the Wrapper streams.
AttachIO(ctx context.Context) (IOStreamer, error)
// Wait blocks until the Exec finishes, errors, or context is canceled.
Wait(ctx context.Context) error
}
type ExecConfig ¶
type HasIOStream ¶
type IOStreamer ¶
func NewIOStreamer ¶
func NewIOStreamer(r types.HijackedResponse, ioStream IOStream) IOStreamer
Click to show internal directories.
Click to hide internal directories.