Versions in this module Expand all Collapse all v0 v0.27.0 Dec 27, 2023 Changes in this version + const Bridge + const Podman + const ReaperDefault + const StderrLog + const StdoutLog + const TestcontainerLabel + const TestcontainerLabelIsReaper + const TestcontainerLabelSessionID + var DefaultLoggingHook = func(logger Logging) ContainerLifecycleHooks + var ErrDuplicateMountTarget = errors.New("duplicate mount target detected") + var ErrInvalidBindMount = errors.New("invalid bind mount") + var ErrReuseEmptyName = errors.New("with reuse option a container name mustn't be empty") + var ReaperDefaultImage = config.ReaperDefaultImage + func DockerImageAuth(ctx context.Context, image string) (string, registry.AuthConfig, error) + func GenericLabels() map[string]string + func LogDockerServerInfo(ctx context.Context, client client.APIClient, logger Logging) + func NewDockerClient() (*client.Client, error) + func SessionID() string + func SkipIfDockerDesktop(t *testing.T, ctx context.Context) + func SkipIfProviderIsNotHealthy(t *testing.T) + type BindMounter interface + GetBindOptions func() *mount.BindOptions + type Container interface + ContainerIP func(context.Context) (string, error) + ContainerIPs func(context.Context) ([]string, error) + CopyDirToContainer func(ctx context.Context, hostDirPath string, containerParentPath string, ...) error + CopyFileFromContainer func(ctx context.Context, filePath string) (io.ReadCloser, error) + CopyFileToContainer func(ctx context.Context, hostFilePath string, containerFilePath string, ...) error + CopyToContainer func(ctx context.Context, fileContent []byte, containerFilePath string, ...) error + Endpoint func(context.Context, string) (string, error) + Exec func(ctx context.Context, cmd []string, options ...tcexec.ProcessOption) (int, io.Reader, error) + FollowOutput func(LogConsumer) + GetContainerID func() string + Host func(context.Context) (string, error) + IsRunning func() bool + Logs func(context.Context) (io.ReadCloser, error) + MappedPort func(context.Context, nat.Port) (nat.Port, error) + Name func(context.Context) (string, error) + NetworkAliases func(context.Context) (map[string][]string, error) + Networks func(context.Context) ([]string, error) + PortEndpoint func(context.Context, nat.Port, string) (string, error) + Ports func(context.Context) (nat.PortMap, error) + SessionID func() string + Start func(context.Context) error + StartLogProducer func(context.Context) error + State func(context.Context) (*types.ContainerState, error) + Stop func(context.Context, *time.Duration) error + StopLogProducer func() error + Terminate func(context.Context) error + func GenericContainer(ctx context.Context, req GenericContainerRequest) (Container, error) + func ParallelContainers(ctx context.Context, reqs ParallelContainerRequest, ...) ([]Container, error) + type ContainerCustomizer interface + Customize func(req *GenericContainerRequest) + type ContainerFile struct + ContainerFilePath string + FileMode int64 + HostFilePath string + type ContainerHook func(ctx context.Context, container Container) error + type ContainerLifecycleHooks struct + PostCreates []ContainerHook + PostStarts []ContainerHook + PostStops []ContainerHook + PostTerminates []ContainerHook + PreCreates []ContainerRequestHook + PreStarts []ContainerHook + PreStops []ContainerHook + PreTerminates []ContainerHook + func (c ContainerLifecycleHooks) Created(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Creating(ctx context.Context) func(req ContainerRequest) error + func (c ContainerLifecycleHooks) Started(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Starting(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Stopped(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Stopping(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Terminated(ctx context.Context) func(container Container) error + func (c ContainerLifecycleHooks) Terminating(ctx context.Context) func(container Container) error + type ContainerMount struct + ReadOnly bool + Source ContainerMountSource + Target ContainerMountTarget + func BindMount(hostPath string, mountTarget ContainerMountTarget) ContainerMount + func VolumeMount(volumeName string, mountTarget ContainerMountTarget) ContainerMount + type ContainerMountSource interface + Source func() string + Type func() MountType + type ContainerMountTarget string + func (t ContainerMountTarget) Target() string + type ContainerMounts []ContainerMount + func Mounts(mounts ...ContainerMount) ContainerMounts + type ContainerOption func(*containerOptions) + func WithImageName(imageName string) ContainerOption + func WithRegistryCredentials(registryCredentials string) ContainerOption + type ContainerProvider interface + Close func() error + Config func() TestcontainersConfig + CreateContainer func(context.Context, ContainerRequest) (Container, error) + Health func(context.Context) error + ReuseOrCreateContainer func(context.Context, ContainerRequest) (Container, error) + RunContainer func(context.Context, ContainerRequest) (Container, error) + type ContainerRequest struct + AlwaysPullImage bool + AutoRemove bool + Binds []string + CapAdd []string + CapDrop []string + Cmd []string + ConfigModifier func(*container.Config) + EnpointSettingsModifier func(map[string]*network.EndpointSettings) + Entrypoint []string + Env map[string]string + ExposedPorts []string + ExtraHosts []string + Files []ContainerFile + HostConfigModifier func(*container.HostConfig) + Hostname string + Image string + ImagePlatform string + ImageSubstitutors []ImageSubstitutor + Labels map[string]string + LifecycleHooks []ContainerLifecycleHooks + Mounts ContainerMounts + Name string + NetworkAliases map[string][]string + NetworkMode container.NetworkMode + Networks []string + Privileged bool + ReaperImage string + ReaperOptions []ContainerOption + RegistryCred string + Resources container.Resources + ShmSize int64 + SkipReaper bool + Tmpfs map[string]string + User string + WaitingFor wait.Strategy + WorkingDir string + func (c *ContainerRequest) BuildOptions() (types.ImageBuildOptions, error) + func (c *ContainerRequest) GetAuthConfigs() map[string]registry.AuthConfig + func (c *ContainerRequest) GetBuildArgs() map[string]*string + func (c *ContainerRequest) GetContext() (io.Reader, error) + func (c *ContainerRequest) GetDockerfile() string + func (c *ContainerRequest) GetRepo() string + func (c *ContainerRequest) GetTag() string + func (c *ContainerRequest) ShouldBuildImage() bool + func (c *ContainerRequest) ShouldKeepBuiltImage() bool + func (c *ContainerRequest) ShouldPrintBuildLog() bool + func (c *ContainerRequest) Validate() error + type ContainerRequestHook func(ctx context.Context, req ContainerRequest) error + type CustomizeRequestOption func(req *GenericContainerRequest) + func CustomizeRequest(src GenericContainerRequest) CustomizeRequestOption + func WithConfigModifier(modifier func(config *container.Config)) CustomizeRequestOption + func WithEndpointSettingsModifier(modifier func(settings map[string]*network.EndpointSettings)) CustomizeRequestOption + func WithHostConfigModifier(modifier func(hostConfig *container.HostConfig)) CustomizeRequestOption + func WithImage(image string) CustomizeRequestOption + func WithImageSubstitutors(fn ...ImageSubstitutor) CustomizeRequestOption + func WithStartupCommand(execs ...Executable) CustomizeRequestOption + func WithWaitStrategy(strategies ...wait.Strategy) CustomizeRequestOption + func WithWaitStrategyAndDeadline(deadline time.Duration, strategies ...wait.Strategy) CustomizeRequestOption + func (opt CustomizeRequestOption) Customize(req *GenericContainerRequest) + type DefaultNetwork string + func (n DefaultNetwork) ApplyDockerTo(opts *DockerProviderOptions) + func (n DefaultNetwork) ApplyGenericTo(opts *GenericProviderOptions) + type DeprecatedContainer interface + GetHostEndpoint func(ctx context.Context, port string) (string, string, error) + GetIPAddress func(ctx context.Context) (string, error) + LivenessCheckPorts func(ctx context.Context) (nat.PortSet, error) + Terminate func(ctx context.Context) error + type DockerBindMountSource struct + HostPath string + func (DockerBindMountSource) Type() MountType + func (s DockerBindMountSource) GetBindOptions() *mount.BindOptions + func (s DockerBindMountSource) Source() string + type DockerClient struct + func NewDockerClientWithOpts(ctx context.Context, opt ...client.Opt) (*DockerClient, error) + func (c *DockerClient) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) + func (c *DockerClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) + func (c *DockerClient) Info(ctx context.Context) (types.Info, error) + func (c *DockerClient) Ping(ctx context.Context) (types.Ping, error) + func (c *DockerClient) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) + type DockerContainer struct + ID string + Image string + WaitingFor wait.Strategy + func (c *DockerContainer) ContainerIP(ctx context.Context) (string, error) + func (c *DockerContainer) ContainerIPs(ctx context.Context) ([]string, error) + func (c *DockerContainer) CopyDirToContainer(ctx context.Context, hostDirPath string, containerParentPath string, ...) error + func (c *DockerContainer) CopyFileFromContainer(ctx context.Context, filePath string) (io.ReadCloser, error) + func (c *DockerContainer) CopyFileToContainer(ctx context.Context, hostFilePath string, containerFilePath string, ...) error + func (c *DockerContainer) CopyToContainer(ctx context.Context, fileContent []byte, containerFilePath string, ...) error + func (c *DockerContainer) Endpoint(ctx context.Context, proto string) (string, error) + func (c *DockerContainer) Exec(ctx context.Context, cmd []string, options ...tcexec.ProcessOption) (int, io.Reader, error) + func (c *DockerContainer) FollowOutput(consumer LogConsumer) + func (c *DockerContainer) GetContainerID() string + func (c *DockerContainer) Host(ctx context.Context) (string, error) + func (c *DockerContainer) IsRunning() bool + func (c *DockerContainer) Logs(ctx context.Context) (io.ReadCloser, error) + func (c *DockerContainer) MappedPort(ctx context.Context, port nat.Port) (nat.Port, error) + func (c *DockerContainer) Name(ctx context.Context) (string, error) + func (c *DockerContainer) NetworkAliases(ctx context.Context) (map[string][]string, error) + func (c *DockerContainer) Networks(ctx context.Context) ([]string, error) + func (c *DockerContainer) PortEndpoint(ctx context.Context, port nat.Port, proto string) (string, error) + func (c *DockerContainer) Ports(ctx context.Context) (nat.PortMap, error) + func (c *DockerContainer) SessionID() string + func (c *DockerContainer) SetLogger(logger Logging) + func (c *DockerContainer) SetProvider(provider *DockerProvider) + func (c *DockerContainer) Start(ctx context.Context) error + func (c *DockerContainer) StartLogProducer(ctx context.Context) error + func (c *DockerContainer) State(ctx context.Context) (*types.ContainerState, error) + func (c *DockerContainer) Stop(ctx context.Context, timeout *time.Duration) error + func (c *DockerContainer) StopLogProducer() error + func (c *DockerContainer) Terminate(ctx context.Context) error + type DockerNetwork struct + Driver string + ID string + Name string + func (n *DockerNetwork) Remove(ctx context.Context) error + type DockerProvider struct + func NewDockerProvider(provOpts ...DockerProviderOption) (*DockerProvider, error) + func (p *DockerProvider) BuildImage(ctx context.Context, img ImageBuildInfo) (string, error) + func (p *DockerProvider) Client() client.APIClient + func (p *DockerProvider) Close() error + func (p *DockerProvider) Config() TestcontainersConfig + func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerRequest) (Container, error) + func (p *DockerProvider) CreateNetwork(ctx context.Context, req NetworkRequest) (Network, error) + func (p *DockerProvider) DaemonHost(ctx context.Context) (string, error) + func (p *DockerProvider) GetGatewayIP(ctx context.Context) (string, error) + func (p *DockerProvider) GetNetwork(ctx context.Context, req NetworkRequest) (types.NetworkResource, error) + func (p *DockerProvider) Health(ctx context.Context) error + func (p *DockerProvider) ListImages(ctx context.Context) ([]ImageInfo, error) + func (p *DockerProvider) PullImage(ctx context.Context, image string) error + func (p *DockerProvider) ReuseOrCreateContainer(ctx context.Context, req ContainerRequest) (Container, error) + func (p *DockerProvider) RunContainer(ctx context.Context, req ContainerRequest) (Container, error) + func (p *DockerProvider) SaveImages(ctx context.Context, output string, images ...string) error + func (p *DockerProvider) SetClient(c client.APIClient) + type DockerProviderOption interface + ApplyDockerTo func(opts *DockerProviderOptions) + func Generic2DockerOptions(opts ...GenericProviderOption) []DockerProviderOption + func WithDefaultBridgeNetwork(bridgeNetworkName string) DockerProviderOption + type DockerProviderOptionFunc func(opts *DockerProviderOptions) + func (f DockerProviderOptionFunc) ApplyDockerTo(opts *DockerProviderOptions) + type DockerProviderOptions struct + type DockerTmpfsMountSource struct + func (s DockerTmpfsMountSource) GetTmpfsOptions() *mount.TmpfsOptions + type DockerVolumeMountSource struct + Name string + func (DockerVolumeMountSource) Type() MountType + func (s DockerVolumeMountSource) GetVolumeOptions() *mount.VolumeOptions + func (s DockerVolumeMountSource) Source() string + type ExecOptions struct + func (ce ExecOptions) Options() []tcexec.ProcessOption + type Executable interface + AsCommand func() []string + Options func() []tcexec.ProcessOption + type FileFromContainer struct + func (fc *FileFromContainer) Close() error + func (fc *FileFromContainer) Read(b []byte) (int, error) + type FromDockerfile struct + AuthConfigs map[string]registry.AuthConfig + BuildArgs map[string]*string + BuildOptionsModifier func(*types.ImageBuildOptions) + Context string + ContextArchive io.Reader + Dockerfile string + KeepImage bool + PrintBuildLog bool + Repo string + Tag string + type GenericBindMountSource struct + HostPath string + func (GenericBindMountSource) Type() MountType + func (s GenericBindMountSource) Source() string + type GenericContainerRequest struct + Logger Logging + ProviderType ProviderType + Reuse bool + Started bool + type GenericNetworkRequest struct + ProviderType ProviderType + type GenericProvider interface + type GenericProviderOption interface + ApplyGenericTo func(opts *GenericProviderOptions) + type GenericProviderOptionFunc func(opts *GenericProviderOptions) + func (f GenericProviderOptionFunc) ApplyGenericTo(opts *GenericProviderOptions) + type GenericProviderOptions struct + DefaultNetwork string + Logger Logging + type GenericTmpfsMountSource struct + func (GenericTmpfsMountSource) Type() MountType + func (s GenericTmpfsMountSource) Source() string + type GenericVolumeMountSource struct + Name string + func (GenericVolumeMountSource) Type() MountType + func (s GenericVolumeMountSource) Source() string + type ImageBuildInfo interface + BuildOptions func() (types.ImageBuildOptions, error) + GetAuthConfigs func() map[string]registry.AuthConfig + GetBuildArgs func() map[string]*string + GetContext func() (io.Reader, error) + GetDockerfile func() string + GetRepo func() string + GetTag func() string + ShouldBuildImage func() bool + ShouldPrintBuildLog func() bool + type ImageInfo struct + ID string + Name string + type ImageProvider interface + ListImages func(context.Context) ([]ImageInfo, error) + PullImage func(context.Context, string) error + SaveImages func(context.Context, string, ...string) error + type ImageSubstitutor interface + Description func() string + Substitute func(image string) (string, error) + type Log struct + Content []byte + LogType string + type LogConsumer interface + Accept func(Log) + type LoggerOption struct + func WithLogger(logger Logging) LoggerOption + func (o LoggerOption) ApplyDockerTo(opts *DockerProviderOptions) + func (o LoggerOption) ApplyGenericTo(opts *GenericProviderOptions) + type Logging interface + Printf func(format string, v ...interface{}) + var Logger Logging = log.New(os.Stderr, "", log.LstdFlags) + func TestLogger(tb testing.TB) Logging + type MountType uint + const MountTypeBind + const MountTypePipe + const MountTypeTmpfs + const MountTypeVolume + type Network interface + Remove func(context.Context) error + func GenericNetwork(ctx context.Context, req GenericNetworkRequest) (Network, error) + type NetworkProvider interface + CreateNetwork func(context.Context, NetworkRequest) (Network, error) + GetNetwork func(context.Context, NetworkRequest) (types.NetworkResource, error) + type NetworkRequest struct + Attachable bool + CheckDuplicate bool + Driver string + EnableIPv6 bool + IPAM *network.IPAM + Internal bool + Labels map[string]string + Name string + ReaperImage string + ReaperOptions []ContainerOption + SkipReaper bool + type ParallelContainerRequest []GenericContainerRequest + type ParallelContainersError struct + Errors []ParallelContainersRequestError + func (gpe ParallelContainersError) Error() string + type ParallelContainersOptions struct + WorkersCount int + type ParallelContainersRequestError struct + Error error + Request GenericContainerRequest + type ProviderType int + const ProviderDefault + const ProviderDocker + const ProviderPodman + func (t ProviderType) GetProvider(opts ...GenericProviderOption) (GenericProvider, error) + type RawCommand struct + func NewRawCommand(cmds []string) RawCommand + func (r RawCommand) AsCommand() []string + type Reaper struct + Endpoint string + Provider ReaperProvider + SessionID string + func NewReaper(ctx context.Context, sessionID string, provider ReaperProvider, ...) (*Reaper, error) + func (r *Reaper) Connect() (chan bool, error) + func (r *Reaper) Labels() map[string]string + type ReaperProvider interface + Config func() TestcontainersConfig + RunContainer func(ctx context.Context, req ContainerRequest) (Container, error) + type TestcontainersConfig struct + CertPath string + Config config.Config + Host string + RyukDisabled bool + RyukPrivileged bool + TLSVerify int + func ReadConfig() TestcontainersConfig + type TmpfsMounter interface + GetTmpfsOptions func() *mount.TmpfsOptions + type VolumeMounter interface + GetVolumeOptions func() *mount.VolumeOptions