docker: github.com/docker/docker/integration/internal/container Index | Files

package container

import "github.com/docker/docker/integration/internal/container"

Index

Package Files

container.go exec.go ops.go states.go

func Create Uses

func Create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) string

Create creates a container with the specified options, asserting that there was no error

func CreateExpectingErr Uses

func CreateExpectingErr(ctx context.Context, t *testing.T, client client.APIClient, errMsg string, ops ...func(*TestContainerConfig))

CreateExpectingErr creates a container, expecting an error with the specified message

func IsInState Uses

func IsInState(ctx context.Context, client client.APIClient, containerID string, state ...string) func(log poll.LogT) poll.Result

IsInState verifies the container is in one of the specified state, e.g., "running", "exited", etc.

func IsStopped Uses

func IsStopped(ctx context.Context, client client.APIClient, containerID string) func(log poll.LogT) poll.Result

IsStopped verifies the container is in stopped state.

func IsSuccessful Uses

func IsSuccessful(ctx context.Context, client client.APIClient, containerID string) func(log poll.LogT) poll.Result

IsSuccessful verifies state.Status == "exited" && state.ExitCode == 0

func Run Uses

func Run(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) string

Run creates and start a container with the specified options

func WithAutoRemove Uses

func WithAutoRemove(c *TestContainerConfig)

WithAutoRemove sets the container to be removed on exit

func WithBind Uses

func WithBind(src, target string) func(*TestContainerConfig)

WithBind sets the bind mount of the container

func WithCgroupnsMode Uses

func WithCgroupnsMode(mode string) func(*TestContainerConfig)

WithCgroupnsMode sets the cgroup namespace mode for the container

func WithCmd Uses

func WithCmd(cmds ...string) func(*TestContainerConfig)

WithCmd sets the comannds of the container

func WithExposedPorts Uses

func WithExposedPorts(ports ...string) func(*TestContainerConfig)

WithExposedPorts sets the exposed ports of the container

func WithExtraHost Uses

func WithExtraHost(extraHost string) func(*TestContainerConfig)

WithExtraHost sets the user defined IP:Host mappings in the container's /etc/hosts file

func WithIPv4 Uses

func WithIPv4(network, ip string) func(*TestContainerConfig)

WithIPv4 sets the specified ip for the specified network of the container

func WithIPv6 Uses

func WithIPv6(network, ip string) func(*TestContainerConfig)

WithIPv6 sets the specified ip6 for the specified network of the container

func WithImage Uses

func WithImage(image string) func(*TestContainerConfig)

WithImage sets the image of the container

func WithLinks(links ...string) func(*TestContainerConfig)

WithLinks sets the links of the container

func WithLogDriver Uses

func WithLogDriver(driver string) func(*TestContainerConfig)

WithLogDriver sets the log driver to use for the container

func WithMount Uses

func WithMount(m mounttypes.Mount) func(*TestContainerConfig)

WithMount adds an mount

func WithName Uses

func WithName(name string) func(*TestContainerConfig)

WithName sets the name of the container

func WithNetworkMode Uses

func WithNetworkMode(mode string) func(*TestContainerConfig)

WithNetworkMode sets the network mode of the container

func WithPidsLimit Uses

func WithPidsLimit(limit *int64) func(*TestContainerConfig)

WithPidsLimit sets the container's "pids-limit

func WithPlatform Uses

func WithPlatform(p *specs.Platform) func(*TestContainerConfig)

WithPlatform specifies the desired platform the image should have.

func WithPrivileged Uses

func WithPrivileged(privileged bool) func(*TestContainerConfig)

WithPrivileged sets privileged mode for the container

func WithRestartPolicy Uses

func WithRestartPolicy(policy string) func(c *TestContainerConfig)

WithRestartPolicy sets container's restart policy

func WithTmpfs Uses

func WithTmpfs(target string) func(config *TestContainerConfig)

WithTmpfs sets a target path in the container to a tmpfs

func WithTty Uses

func WithTty(tty bool) func(*TestContainerConfig)

WithTty sets the TTY mode of the container

func WithUser Uses

func WithUser(user string) func(c *TestContainerConfig)

WithUser sets the user

func WithVolume Uses

func WithVolume(target string) func(*TestContainerConfig)

WithVolume sets the volume of the container

func WithWorkingDir Uses

func WithWorkingDir(dir string) func(*TestContainerConfig)

WithWorkingDir sets the working dir of the container

type ExecResult Uses

type ExecResult struct {
    ExitCode int
    // contains filtered or unexported fields
}

ExecResult represents a result returned from Exec()

func Exec Uses

func Exec(ctx context.Context, cli client.APIClient, id string, cmd []string) (ExecResult, error)

Exec executes a command inside a container, returning the result containing stdout, stderr, and exit code. Note:

- this is a synchronous operation;
- cmd stdin is closed.

func (*ExecResult) Combined Uses

func (res *ExecResult) Combined() string

Combined returns combined stdout and stderr output of a command run by Exec()

func (*ExecResult) Stderr Uses

func (res *ExecResult) Stderr() string

Stderr returns stderr output of a command run by Exec()

func (*ExecResult) Stdout Uses

func (res *ExecResult) Stdout() string

Stdout returns stdout output of a command run by Exec()

type TestContainerConfig Uses

type TestContainerConfig struct {
    Name             string
    Config           *container.Config
    HostConfig       *container.HostConfig
    NetworkingConfig *network.NetworkingConfig
    Platform         *specs.Platform
}

TestContainerConfig holds container configuration struct that are used in api calls.

Package container imports 18 packages (graph). Updated 2020-08-03. Refresh now. Tools for package owners.