docker

package
v1.0.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: EPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "Docker Client"
)

Variables

This section is empty.

Functions

func ParseAnnotationsString

func ParseAnnotationsString(annotationsString string) (map[string]string, error)

ParseAnnotationsString parses annotations JSON string into a map

func ResolveVolumeMountPath

func ResolveVolumeMountPath(hostDestination string, volumeMappingType models.VolumeMappingType, microserviceUUID string) (string, error)

ResolveVolumeMountPath resolves volume mount paths for VOLUME_MOUNT type

Types

type Client

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

Client wraps the Docker client with reconnection logic

func GetInstance

func GetInstance() *Client

GetInstance returns the singleton Docker client instance

func (*Client) AreMicroserviceAndContainerEqual

func (c *Client) AreMicroserviceAndContainerEqual(containerID string, ms *models.Microservice) bool

AreMicroserviceAndContainerEqual checks if a microservice configuration matches a container

func (*Client) Close

func (c *Client) Close() error

Close closes the Docker client

func (*Client) CreateContainer

func (c *Client) CreateContainer(ms *models.Microservice, hostName string) (string, error)

CreateContainer creates a container from microservice configuration

func (*Client) CreateExecSession

func (c *Client) CreateExecSession(containerID string, command []string) (string, error)

CreateExecSession creates an exec session in a container

func (*Client) DockerPrune

func (c *Client) DockerPrune() (image.PruneReport, error)

DockerPrune prunes Docker images (removes unused images)

func (*Client) FindLocalImage

func (c *Client) FindLocalImage(imageName string) (bool, error)

FindLocalImage checks if an image exists locally

func (*Client) GetAllContainers

func (c *Client) GetAllContainers() ([]Container, error)

GetAllContainers returns all containers regardless of state.

func (*Client) GetClient

func (c *Client) GetClient() *client.Client

GetClient returns the underlying Docker client (thread-safe)

func (*Client) GetContainer

func (c *Client) GetContainer(microserviceUUID string) (*Container, error)

GetContainer retrieves a container by microservice UUID

func (*Client) GetContainerByID

func (c *Client) GetContainerByID(containerID string) (*Container, error)

GetContainerByID retrieves a container by its Docker-assigned ID.

func (*Client) GetContainerIPAddress

func (c *Client) GetContainerIPAddress(containerID string) (string, error)

GetContainerIPAddress gets the IPv4 address of a container

func (*Client) GetContainerInspectRaw

func (c *Client) GetContainerInspectRaw(containerID string) ([]byte, error)

GetContainerInspectRaw returns raw Docker inspect JSON payload for a container.

func (*Client) GetContainerMicroserviceUUID

func (c *Client) GetContainerMicroserviceUUID(cont Container) string

GetContainerMicroserviceUUID extracts microservice UUID from container name

func (*Client) GetContainerName

func (c *Client) GetContainerName(cont Container) string

GetContainerName extracts container name from container

func (*Client) GetContainerStartedAt

func (c *Client) GetContainerStartedAt(containerID string) (int64, error)

GetContainerStartedAt returns container last start epoch time in milliseconds

func (*Client) GetContainerStats

func (c *Client) GetContainerStats(containerID string) (*ContainerStats, error)

GetContainerStats gets container statistics

func (*Client) GetContainerStatus

func (c *Client) GetContainerStatus(containerID string) (string, error)

GetContainerStatus retrieves the status of a container

func (*Client) GetContext

func (c *Client) GetContext() context.Context

GetContext returns the context for Docker operations

func (*Client) GetDockerBridgeName

func (c *Client) GetDockerBridgeName() (string, error)

GetDockerBridgeName returns the Docker default bridge name

func (*Client) GetExecSessionExitCode

func (c *Client) GetExecSessionExitCode(execID string) (int, error)

GetExecSessionExitCode returns an exit code only for completed exec sessions.

func (*Client) GetExecSessionStatus

func (c *Client) GetExecSessionStatus(execID string) (*client.ExecInspectResult, error)

GetExecSessionStatus gets the status of an exec session

func (*Client) GetImageInspect

func (c *Client) GetImageInspect(imageName string) (*image.InspectResponse, error)

GetImageInspect inspects an image

func (*Client) GetImages

func (c *Client) GetImages() ([]image.Summary, error)

GetImages returns all Docker images

func (*Client) GetInspectContainersImage

func (c *Client) GetInspectContainersImage(containerID string) (string, error)

GetInspectContainersImage gets the image name from container inspection

func (*Client) GetMicroserviceStatus

func (c *Client) GetMicroserviceStatus(containerID, _ string) (*models.MicroserviceStatus, error)

GetMicroserviceStatus gets the microservice status from container inspection

func (*Client) GetNatsMicroserviceIP

func (c *Client) GetNatsMicroserviceIP() (string, error)

GetNatsMicroserviceIP gets the IP address of a running NATS microservice container.

func (*Client) GetRouterMicroserviceIP

func (c *Client) GetRouterMicroserviceIP() (string, error)

GetRouterMicroserviceIP gets the IP address of a running router microservice container.

func (*Client) GetRunningContainers

func (c *Client) GetRunningContainers() ([]Container, error)

GetRunningContainers returns running containers only.

func (*Client) GetRunningNonIofogContainers

func (c *Client) GetRunningNonIofogContainers() ([]Container, error)

GetRunningNonIofogContainers returns running containers not managed by ioFog

func (*Client) Init

func (c *Client) Init(dockerURL, apiVersion string) error

Init initializes the Docker client with the given configuration

func (*Client) IsContainerRunning

func (c *Client) IsContainerRunning(containerID string) (bool, error)

IsContainerRunning checks if a container is running

func (*Client) KillContainer

func (c *Client) KillContainer(containerID string) error

KillContainer sends SIGKILL to a container.

func (*Client) KillExecSession

func (c *Client) KillExecSession(execID string) error

KillExecSession kills an exec session

func (*Client) LoadImage

func (c *Client) LoadImage(archive io.Reader) ([]LoadedImage, error)

LoadImage imports a Docker image archive stream.

func (*Client) PruneContainers

func (c *Client) PruneContainers() (container.PruneReport, error)

PruneContainers removes stopped containers.

func (*Client) PruneVolumes

func (c *Client) PruneVolumes() (volume.PruneReport, error)

PruneVolumes removes unused local volumes.

func (*Client) PullImage

func (c *Client) PullImage(imageName, _ string, platform string, registry *models.Registry, progressCallback func(float32)) error

PullImage pulls an image from a registry with authentication

func (*Client) ReInit

func (c *Client) ReInit() error

ReInit reinitializes the Docker client

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(containerID string, removeVolumes bool) error

RemoveContainer removes a container

func (*Client) RemoveImage

func (c *Client) RemoveImage(imageID string) error

RemoveImage removes an image by ID

func (*Client) RemoveNamedVolume

func (c *Client) RemoveNamedVolume(name string) error

RemoveNamedVolume deletes a docker named volume when it exists.

func (*Client) ResizeExecSession

func (c *Client) ResizeExecSession(execID string, cols, rows uint32) error

ResizeExecSession resizes a running TTY exec session.

func (*Client) StartContainer

func (c *Client) StartContainer(containerID string) error

StartContainer starts a container

func (*Client) StartExecSession

func (c *Client) StartExecSession(execID string, stdin io.Reader, stdout, stderr io.Writer) error

StartExecSession starts an exec session with I/O handling

func (*Client) StopContainer

func (c *Client) StopContainer(containerID string) error

StopContainer stops a container

func (*Client) TailContainerLogs

func (c *Client) TailContainerLogs(containerID string, sessionID, microserviceUUID string, handler LogTailHandler, tailConfig *TailConfig) error

TailContainerLogs tails container logs using Docker API

type Container

type Container struct {
	ID     string
	Names  []string
	Image  string
	Status string
	State  string
	Labels map[string]string
}

Container represents a Docker container

type ContainerStats

type ContainerStats struct {
	CPUUsage    float32
	MemoryUsage int64
	Timestamp   time.Time
}

ContainerStats represents container statistics

type LoadedImage

type LoadedImage struct {
	Name string
	ID   string
}

LoadedImage is one entry produced by ImageLoad import stream.

type LogTailHandler

type LogTailHandler interface {
	OnLogLine(sessionID, microserviceUUID string, lineBytes []byte, streamType StreamType)
	OnComplete(sessionID string)
	OnError(sessionID string, err error)
}

LogTailHandler handles log lines from container logs

type StreamType

type StreamType int

StreamType represents the stream type (stdout or stderr)

const (
	STDOUT StreamType = iota
	STDERR
)

type TailConfig

type TailConfig struct {
	Follow bool
	Lines  int
	Since  string // ISO 8601 timestamp
	Until  string // ISO 8601 timestamp
}

TailConfig represents configuration for log tailing

Jump to

Keyboard shortcuts

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