docker

package
v0.1.0-beta.18 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerNetworkIP

func ContainerNetworkIP(containerInfo container.InspectResponse, networkName string) (string, error)

ContainerNetworkInfo extracts the container's IP address

func EnsureImageUpToDate

func EnsureImageUpToDate(ctx context.Context, cli *client.Client, logger *slog.Logger, imageConfig config.Image) error

func EnsureVolumes

func EnsureVolumes(ctx context.Context, cli *client.Client, logger *slog.Logger, appName string, volumes []string) error

EnsureVolumes creates named volumes with labels if they don't exist. It parses volume specifications from the config (e.g., "postgres-data:/var/lib/postgresql") and creates the named volumes with the app label for later cleanup.

func ExecInContainer

func ExecInContainer(ctx context.Context, cli *client.Client, containerID string, cmd []string) (stdout, stderr string, exitCode int, err error)

ExecInContainer executes a command in a running container and returns the output.

func GetAppContainers

func GetAppContainers(ctx context.Context, cli *client.Client, listAll bool, appName string) ([]container.Summary, error)

GetAppContainers returns a slice of container summaries filtered by labels.

Parameters:

  • ctx: the context for the Docker API requests.
  • cli: the Docker client used to interact with the Docker daemon.
  • listAll: if true, the function returns all containers including stopped ones; if false, only running containers are returned.
  • appName: if not empty, only containers associated with the given app name are returned.

Returns:

  • A slice of container summaries.
  • An error if something went wrong during the container listing.

func GetRegistryServer

func GetRegistryServer(imageConfig *config.Image) string

func LoadImageFromTar

func LoadImageFromTar(ctx context.Context, cli *client.Client, tarPath string) error

func NewClient

func NewClient(ctx context.Context) (*client.Client, error)

func PruneImages

func PruneImages(ctx context.Context, cli *client.Client, logger *slog.Logger) (uint64, error)

PruneImages removes dangling (unused) Docker images and returns the amount of space reclaimed.

func PushImage

func PushImage(ctx context.Context, cli *client.Client, imageRef string, imageConfig *config.Image) error

func RemoveContainers

func RemoveContainers(ctx context.Context, cli *client.Client, logger *slog.Logger, appName, ignoreDeploymentID string) (removedIDs []string, err error)

func RemoveImages

func RemoveImages(ctx context.Context, cli *client.Client, logger *slog.Logger, appName, ignoreDeploymentID string, deploymentsToKeep int) error

RemoveImages removes extra (duplicate) image tags for a given app, keeping only the newest N tags based on the deploymentID. Running containers reference the image by digest; if an image is in use we allow removal of duplicate tags as long as at least one tag is preserved.

func RemoveVolumes

func RemoveVolumes(ctx context.Context, cli *client.Client, logger *slog.Logger, appName string) error

func StopContainers

func StopContainers(ctx context.Context, cli *client.Client, logger *slog.Logger, appName, ignoreDeploymentID string) (stoppedIDs []string, err error)

Types

type ContainerRunResult

type ContainerRunResult struct {
	ID           string
	DeploymentID string
	ReplicaID    int
}

func RunContainer

func RunContainer(ctx context.Context, cli *client.Client, deploymentID, imageRef string, targetConfig config.TargetConfig) ([]ContainerRunResult, error)

type HealthCheckResult

type HealthCheckResult struct {
	IP  string // Container IP address on the haloy network (only set on success)
	Err error  // nil if healthy
}

HealthCheckResult contains the result of a container health check.

func HealthCheckContainer

func HealthCheckContainer(ctx context.Context, cli *client.Client, logger *slog.Logger, containerID string, containerInfo container.InspectResponse) HealthCheckResult

HealthCheckContainer performs health checks on a container and returns its IP address on success. It accepts a pre-fetched container.InspectResponse but will re-inspect if needed. The function checks: 1. Container is running (and stable, not in restart loop) 2. Docker health status (if configured) 3. HTTP health check endpoint (if no Docker healthcheck) 4. Container has a valid IP on the haloy network

type RemoveContainersResult

type RemoveContainersResult struct {
	ID           string
	DeploymentID string
}

Jump to

Keyboard shortcuts

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