Documentation ¶
Index ¶
- Variables
- type Command
- type Container
- func (c *Container) AttachIO(stdout io.Writer, stdin io.Reader) error
- func (c *Container) Create() error
- func (c *Container) Exec(cmd Command, cfg RunConfig) (*Exec, error)
- func (c *Container) Inspect(ctx context.Context) (types.ContainerJSON, error)
- func (c *Container) Remove() error
- func (c *Container) Start(timeout time.Duration) error
- func (c *Container) Stop(ctx context.Context) error
- func (c *Container) Wait() error
- type ContainerConfig
- type ContainerStatus
- type Exec
- type RunConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultCmd an infinite command to keep the container running. DefaultCmd = Command{"sh", "-c", "while true; do sleep 1; done"} )
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func CreateContainer ¶
func CreateContainer(ctx context.Context, cfg ContainerConfig) (*Container, error)
CreateContainer returns an instance of a created Container, use this if you want to perform things before starting the container. Eg attaching IO.
func NewContainer ¶
func NewContainer(ctx context.Context, cfg ContainerConfig) (*Container, error)
func StartContainer ¶
func StartContainer(ctx context.Context, cfg ContainerConfig) (*Container, error)
StartContainer returns an instance of a started Container, use this for running multiple Exec inside the same Container.
type ContainerConfig ¶
type ContainerConfig struct { Image string // Required Logger *zap.Logger Labels map[string]string // container labels name:value Directories map[string]string // Directories to mount to container src:target WorkingDir string // Required Name string // ContainerName defaults to randomly generated // The Command to start the container with, defaults to DefaultCmd Cmd Command // Automatically remove the container when it exits AutoRemove bool // contains filtered or unexported fields }
ContainerConfig contains the configuration data about a container.
func (*ContainerConfig) String ¶
func (cc *ContainerConfig) String() string
String is the command as it can be run from the terminal.
type ContainerStatus ¶
type ContainerStatus string
const (
ContainerStatusRunning ContainerStatus = "running"
)
type Exec ¶
type Exec struct { types.IDResponse // contains filtered or unexported fields }
Exec is a standalone command running in an already running container.
Click to show internal directories.
Click to hide internal directories.