docker

package
v0.0.0-...-1fafc1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPortMapping

func GetPortMapping(internal, external int) string

GetPortMapping returns a formatted port mapping string

Types

type ContainerConfig

type ContainerConfig struct {
	ID          string
	Name        string
	Image       string
	Environment map[string]string
	Ports       []container.PortMapping
}

ContainerConfig holds basic container configuration

type ContainerLifecycleManager

type ContainerLifecycleManager struct {
	// contains filtered or unexported fields
}

ContainerLifecycleManager manages container lifecycle operations

func NewContainerLifecycleManager

func NewContainerLifecycleManager() *ContainerLifecycleManager

NewContainerLifecycleManager creates a new container lifecycle manager

func (*ContainerLifecycleManager) GetContainer

func (c *ContainerLifecycleManager) GetContainer(containerID string) (*DockerContainer, error)

GetContainer returns a container by ID

func (*ContainerLifecycleManager) ListContainers

func (c *ContainerLifecycleManager) ListContainers() map[string]*DockerContainer

ListContainers returns all registered containers

func (*ContainerLifecycleManager) PortManager

func (c *ContainerLifecycleManager) PortManager() *PortManager

PortManager returns the port manager

func (*ContainerLifecycleManager) RegisterContainer

func (c *ContainerLifecycleManager) RegisterContainer(dockerContainer *DockerContainer)

RegisterContainer registers a container for lifecycle management

func (*ContainerLifecycleManager) StartAll

StartAll starts all registered containers

func (*ContainerLifecycleManager) StopAll

StopAll stops all registered containers

func (*ContainerLifecycleManager) UnregisterContainer

func (c *ContainerLifecycleManager) UnregisterContainer(containerID string)

UnregisterContainer unregisters a container from lifecycle management

type DockerContainer

type DockerContainer struct {
	// contains filtered or unexported fields
}

DockerContainer wraps testcontainers.Container with additional configuration

func NewDockerContainer

func NewDockerContainer(config *ContainerConfig) *DockerContainer

NewDockerContainer creates a new DockerContainer with the given configuration

func (*DockerContainer) Config

func (d *DockerContainer) Config() *ContainerConfig

Config returns the container configuration

func (*DockerContainer) ConnectionString

func (d *DockerContainer) ConnectionString() string

ConnectionString returns the connection string for the container

func (*DockerContainer) Container

func (d *DockerContainer) Container() testcontainers.Container

Container returns the underlying testcontainers.Container

func (*DockerContainer) Exec

func (d *DockerContainer) Exec(ctx context.Context, cmd []string) error

Exec executes a command in the container

func (*DockerContainer) HealthCheck

func (d *DockerContainer) HealthCheck(ctx context.Context) error

HealthCheck performs a health check on the container

func (*DockerContainer) Host

func (d *DockerContainer) Host() string

Host returns the host address where the container is accessible

func (*DockerContainer) ID

func (d *DockerContainer) ID() string

ID returns the unique identifier of the container

func (*DockerContainer) Image

func (d *DockerContainer) Image() string

Image returns the image of the container

func (*DockerContainer) IsRunning

func (d *DockerContainer) IsRunning() bool

IsRunning returns true if the container is currently running

func (*DockerContainer) Logs

func (d *DockerContainer) Logs(ctx context.Context) (io.Reader, error)

Logs returns the container logs

func (*DockerContainer) Name

func (d *DockerContainer) Name() string

Name returns the name of the container

func (*DockerContainer) Port

func (d *DockerContainer) Port(internal int) (int, error)

Port returns the mapped external port for the given internal port

func (*DockerContainer) SetContainer

func (d *DockerContainer) SetContainer(c testcontainers.Container)

SetContainer sets the underlying testcontainers.Container

func (*DockerContainer) Start

func (d *DockerContainer) Start(ctx context.Context) error

Start starts the container

func (*DockerContainer) Stop

func (d *DockerContainer) Stop(ctx context.Context) error

Stop stops the container

func (*DockerContainer) WaitForReady

func (d *DockerContainer) WaitForReady(ctx context.Context, timeout time.Duration) error

WaitForReady waits for the container to be ready with a timeout

type PortManager

type PortManager struct {
	// contains filtered or unexported fields
}

PortManager manages port mappings and allocations

func NewPortManager

func NewPortManager() *PortManager

NewPortManager creates a new port manager

func (*PortManager) AllocatePort

func (p *PortManager) AllocatePort(containerID string, port int)

AllocatePort allocates a port for a container

func (*PortManager) DeallocateAllPorts

func (p *PortManager) DeallocateAllPorts(containerID string)

DeallocateAllPorts deallocates all ports for a container

func (*PortManager) DeallocatePort

func (p *PortManager) DeallocatePort(containerID string, port int)

DeallocatePort deallocates a port for a container

func (*PortManager) GetAllocatedPorts

func (p *PortManager) GetAllocatedPorts(containerID string) []int

GetAllocatedPorts returns all allocated ports for a container

func (*PortManager) IsPortAllocated

func (p *PortManager) IsPortAllocated(port int) bool

IsPortAllocated checks if a port is allocated for any container

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL