containerkit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package containerkit is a wrapper around the docker compose CLI. It provides a programmatic interface for managing docker compose projects by mapping docker compose commands onto typed option structs.

Package containerkit provides the container config for the wrapped client. it is built to be created in a declarative way.

Index

Constants

View Source
const (
	AUDIT_WRITE        = hc.AUDIT_WRITE
	CHOWN              = hc.CHOWN
	DAC_OVERRIDE       = hc.DAC_OVERRIDE
	FOWNER             = hc.FOWNER
	FSETID             = hc.FSETID
	KILL               = hc.KILL
	MKNOD              = hc.MKNOD
	NET_BIND_SERVICE   = hc.NET_BIND_SERVICE
	NET_RAW            = hc.NET_RAW
	SETFCAP            = hc.SETFCAP
	SETGID             = hc.SETGID
	SETPCAP            = hc.SETPCAP
	SETUID             = hc.SETUID
	SYS_CHROOT         = hc.SYS_CHROOT
	AUDIT_CONTROL      = hc.AUDIT_CONTROL
	AUDIT_READ         = hc.AUDIT_READ
	BLOCK_SUSPEND      = hc.BLOCK_SUSPEND
	BPF                = hc.BPF
	CHECKPOINT_RESTORE = hc.CHECKPOINT_RESTORE
	DAC_READ_SEARCH    = hc.DAC_READ_SEARCH
	SYS_ADMIN          = hc.SYS_ADMIN
	SYS_BOOT           = hc.SYS_BOOT
	SYS_MODULE         = hc.SYS_MODULE
	SYS_PACCT          = hc.SYS_PACCT
	SYS_RAWIO          = hc.SYS_RAWIO
	SYS_TIME           = hc.SYS_TIME
	SYS_TTY_CONFIG     = hc.SYS_TTY_CONFIG
	SYSLOG             = hc.SYSLOG
	IPC_LOCK           = hc.IPC_LOCK
	IPC_OWNER          = hc.IPC_OWNER
	LEASE              = hc.LEASE
	LINUX_IMMUTABLE    = hc.LINUX_IMMUTABLE
	SYS_NICE           = hc.SYS_NICE
	SYS_PTRACE         = hc.SYS_PTRACE
	SYS_RESOURCE       = hc.SYS_RESOURCE
	WAKE_ALARM         = hc.WAKE_ALARM
	NET_ADMIN          = hc.NET_ADMIN
	NET_BROADCAST      = hc.NET_BROADCAST
	MAC_ADMIN          = hc.MAC_ADMIN
	MAC_OVERRIDE       = hc.MAC_OVERRIDE
	PERFMON            = hc.PERFMON
	ALL                = hc.ALL
)
View Source
const (
	RestartPolicyNo            = hc.RestartPolicyNo
	RestartPolicyOnFailure     = hc.RestartPolicyOnFailure
	RestartPolicyAlways        = hc.RestartPolicyAlways
	RestartPolicyUnlessStopped = hc.RestartPolicyUnlessStopped
)
View Source
const (
	PropagationRPrivate = mount.PropagationRPrivate
	PropagationPrivate  = mount.PropagationPrivate
	PropagationRShared  = mount.PropagationRShared
	PropagationShared   = mount.PropagationShared
	PropagationRSlave   = mount.PropagationRSlave
	PropagationSlave    = mount.PropagationSlave
)
View Source
const (
	MountBind      = mount.MountTypeBind
	MountVolume    = mount.MountTypeVolume
	MountTmpfs     = mount.MountTypeTmpfs
	MountNamedPipe = mount.MountTypeNamedPipe
)

Variables

View Source
var (
	ErrComposeError        = fmt.Errorf("compose error")
	ErrComposeFlagError    = fmt.Errorf("compose flag error")
	ErrComposeUpError      = fmt.Errorf("compose up error")
	ErrComposeDownError    = fmt.Errorf("compose down error")
	ErrComposeLogsError    = fmt.Errorf("compose logs error")
	ErrComposeKillError    = fmt.Errorf("compose kill error")
	ErrComposeEventsError  = fmt.Errorf("compose events error")
	ErrComposePsError      = fmt.Errorf("compose ps error")
	ErrComposeStartError   = fmt.Errorf("compose start error")
	ErrComposeStopError    = fmt.Errorf("compose stop error")
	ErrComposeRestartError = fmt.Errorf("compose restart error")
	ErrComposeBuildError   = fmt.Errorf("compose build error")
	ErrComposePullError    = fmt.Errorf("compose pull error")
	ErrComposeExecError    = fmt.Errorf("compose exec error")
	ErrComposeAttachError  = fmt.Errorf("compose attach error")
	ErrComposeCommitError  = fmt.Errorf("compose commit error")
	ErrComposeConfigError  = fmt.Errorf("compose config error")
	ErrComposeCpError      = fmt.Errorf("compose cp error")
	ErrComposeCreateError  = fmt.Errorf("compose create error")
	ErrComposeExportError  = fmt.Errorf("compose export error")
	ErrComposeImagesError  = fmt.Errorf("compose images error")
	ErrComposeLsError      = fmt.Errorf("compose ls error")
	ErrComposePauseError   = fmt.Errorf("compose pause error")
	ErrComposePortError    = fmt.Errorf("compose port error")
	ErrComposePublishError = fmt.Errorf("compose publish error")
	ErrComposePushError    = fmt.Errorf("compose push error")
	ErrComposeRmError      = fmt.Errorf("compose rm error")
	ErrComposeRunError     = fmt.Errorf("compose run error")
	ErrComposeScaleError   = fmt.Errorf("compose scale error")
	ErrComposeStatsError   = fmt.Errorf("compose stats error")
	ErrComposeTopError     = fmt.Errorf("compose top error")
	ErrComposeUnpauseError = fmt.Errorf("compose unpause error")
	ErrComposeVersionError = fmt.Errorf("compose version error")
	ErrComposeVolumesError = fmt.Errorf("compose volumes error")
	ErrComposeWaitError    = fmt.Errorf("compose wait error")
	ErrComposeWatchError   = fmt.Errorf("compose watch error")
)

Errors for the compose command and its setters.

Functions

func And

func And(preds ...bool) func() bool

func AndFn

func AndFn(preds ...PredicateClosure) func() bool

func IsComposeAttachError

func IsComposeAttachError(err error) bool

func IsComposeBuildError

func IsComposeBuildError(err error) bool

func IsComposeCommitError

func IsComposeCommitError(err error) bool

func IsComposeConfigError

func IsComposeConfigError(err error) bool

func IsComposeCpError

func IsComposeCpError(err error) bool

func IsComposeCreateError

func IsComposeCreateError(err error) bool

func IsComposeDownError

func IsComposeDownError(err error) bool

IsComposeDownError checks if the error is a ComposeDownError.

func IsComposeError

func IsComposeError(err error) bool

IsComposeError checks if the error is a ComposeError.

func IsComposeEventsError

func IsComposeEventsError(err error) bool

IsComposeEventsError checks if the error is a ComposeEventsError.

func IsComposeExecError

func IsComposeExecError(err error) bool

func IsComposeExportError

func IsComposeExportError(err error) bool

func IsComposeFlagError

func IsComposeFlagError(err error) bool

IsComposeFlagError checks if the error is a ComposeFlagError.

func IsComposeImagesError

func IsComposeImagesError(err error) bool

func IsComposeKillError

func IsComposeKillError(err error) bool

IsComposeKillError checks if the error is a ComposeKillError.

func IsComposeLogsError

func IsComposeLogsError(err error) bool

IsComposeLogsError checks if the error is a ComposeLogsError.

func IsComposeLsError

func IsComposeLsError(err error) bool

func IsComposePauseError

func IsComposePauseError(err error) bool

func IsComposePortError

func IsComposePortError(err error) bool

func IsComposePsError

func IsComposePsError(err error) bool

func IsComposePublishError

func IsComposePublishError(err error) bool

func IsComposePullError

func IsComposePullError(err error) bool

func IsComposePushError

func IsComposePushError(err error) bool

func IsComposeRestartError

func IsComposeRestartError(err error) bool

func IsComposeRmError

func IsComposeRmError(err error) bool

func IsComposeRunError

func IsComposeRunError(err error) bool

func IsComposeScaleError

func IsComposeScaleError(err error) bool

func IsComposeStartError

func IsComposeStartError(err error) bool

func IsComposeStatsError

func IsComposeStatsError(err error) bool

func IsComposeStopError

func IsComposeStopError(err error) bool

func IsComposeTopError

func IsComposeTopError(err error) bool

func IsComposeUnpauseError

func IsComposeUnpauseError(err error) bool

func IsComposeUpError

func IsComposeUpError(err error) bool

IsComposeUpError checks if the error is a ComposeUpError.

func IsComposeVersionError

func IsComposeVersionError(err error) bool

func IsComposeVolumesError

func IsComposeVolumesError(err error) bool

func IsComposeWaitError

func IsComposeWaitError(err error) bool

func IsComposeWatchError

func IsComposeWatchError(err error) bool

func NewDockerFile

func NewDockerFile() *dockerFile

NewDockerFile creates a new dockerfile which allows you to create a dockerfile string with step by step instructions via builder pattern

note: Not safe for concurrent use.

func Or

func Or(preds ...bool) func() bool

func OrFn

func OrFn(preds ...PredicateClosure) func() bool

func WhenTrueOpt

func WhenTrueOpt[T any, O ~func(T) error](check bool, fns ...O) O

WhenTrueOpt applies option funcs (SetContainerConfig, SetServiceConfig, etc.) only if check is true.

Types

type Attach

type Attach struct {
	DetachKeys string
	Index      *int
	NoStdin    bool
	NoSigProxy bool // --sig-proxy=false; Compose defaults to true

	Writer   io.Writer
	Stdin    io.Reader
	Profiles []string
	Flags    []string
	Service  string // required
}

Attach is the options for the compose attach command. Service is required.

func (*Attach) GenerateFlags

func (opt *Attach) GenerateFlags() ([]string, error)

type BuildSpec

type BuildSpec struct {
	Context          string
	Dockerfile       string
	DockerfileInline string
	Args             map[string]string
	Labels           map[string]string
	Tags             []string
	Target           string
	Network          string
	NoCache          bool
	Pull             bool
	Privileged       bool
	Platforms        []string
	CacheFrom        []string
	CacheTo          []string
}

BuildSpec is Compose service build configuration.

type Capability

type Capability = hc.Capability

Capability is a Linux capability granted or dropped on a container.

type CheckClosure

type CheckClosure func() (bool, error)

type Commit

type Commit struct {
	Author  string
	Change  []string // Dockerfile instructions applied to the image
	Index   *int
	Message string
	NoPause bool // --pause=false; Compose defaults to true

	Writer     io.Writer
	Profiles   []string
	Flags      []string
	Service    string // required
	Repository string // optional REPOSITORY[:TAG]
}

Commit is the options for the compose commit command. Service is required.

func (*Commit) GenerateFlags

func (opt *Commit) GenerateFlags() ([]string, error)

type Compose

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

Compose runs docker compose commands against a Project (YAML on stdin).

func NewCompose

func NewCompose(project *Project) *Compose

NewCompose returns a Compose runner for the given project.

func (*Compose) Attach

func (c *Compose) Attach(ctx context.Context, opt *Attach) error

Attach runs the docker compose attach command. Service is required.

func (*Compose) Build

func (c *Compose) Build(ctx context.Context, opt *ComposeBuild) error

Build runs the docker compose build command.

func (*Compose) Commit

func (c *Compose) Commit(ctx context.Context, opt *Commit) error

Commit runs the docker compose commit command. Service is required.

func (*Compose) Config

func (c *Compose) Config(ctx context.Context, opt *ComposeConfig) error

Config runs the docker compose config command.

func (*Compose) Cp

func (c *Compose) Cp(ctx context.Context, opt *Cp) error

Cp runs the docker compose cp command. Source and Dest are required.

func (*Compose) Create

func (c *Compose) Create(ctx context.Context, opt *Create) error

Create runs the docker compose create command.

func (*Compose) Down

func (c *Compose) Down(ctx context.Context, opt *Down) error

Down runs the docker compose down command. A nil opt uses defaults (writer is os.Stdout).

func (*Compose) Events

func (c *Compose) Events(ctx context.Context, service string, profiles ...string) (<-chan Events, <-chan error, error)

Events runs the docker compose events command. Pass an empty service string to receive events for all services. When the project uses profiles, pass the same profiles used for up/down (e.g. Events(ctx, "", "minimal", "full")).

func (*Compose) Exec

func (c *Compose) Exec(ctx context.Context, opt *Exec) error

Exec runs the docker compose exec command. Service and Command must be set on opt.

func (*Compose) Export

func (c *Compose) Export(ctx context.Context, opt *ComposeExport) error

Export runs the docker compose export command. Service is required.

func (*Compose) Images

func (c *Compose) Images(ctx context.Context, opt *Images) error

Images runs the docker compose images command.

func (*Compose) Kill

func (c *Compose) Kill(ctx context.Context, opt *Kill) error

Kill runs the docker compose kill command. A nil opt uses defaults (writer is os.Stdout).

func (*Compose) Logs

func (c *Compose) Logs(ctx context.Context, opt *Logs) error

Logs runs the docker compose logs command. A nil opt uses defaults (writer is os.Stdout).

func (*Compose) Ls

func (c *Compose) Ls(ctx context.Context, opt *Ls) error

Ls runs the docker compose ls command.

func (*Compose) Pause

func (c *Compose) Pause(ctx context.Context, opt *Pause) error

Pause runs the docker compose pause command.

func (*Compose) Port

func (c *Compose) Port(ctx context.Context, opt *Port) error

Port runs the docker compose port command. Service and PrivatePort are required.

func (*Compose) Ps

func (c *Compose) Ps(ctx context.Context, opt *Ps) error

Ps runs the docker compose ps command.

func (*Compose) Publish

func (c *Compose) Publish(ctx context.Context, opt *Publish) error

Publish runs the docker compose publish command. Repository is required.

func (*Compose) Pull

func (c *Compose) Pull(ctx context.Context, opt *Pull) error

Pull runs the docker compose pull command.

func (*Compose) Push

func (c *Compose) Push(ctx context.Context, opt *Push) error

Push runs the docker compose push command.

func (*Compose) Restart

func (c *Compose) Restart(ctx context.Context, opt *Restart) error

Restart runs the docker compose restart command.

func (*Compose) Rm

func (c *Compose) Rm(ctx context.Context, opt *Rm) error

Rm runs the docker compose rm command.

func (*Compose) Run

func (c *Compose) Run(ctx context.Context, opt *Run) error

Run runs the docker compose run command. Service is required.

func (*Compose) Scale

func (c *Compose) Scale(ctx context.Context, opt *Scale) error

Scale runs the docker compose scale command. Replicas is required.

func (*Compose) Start

func (c *Compose) Start(ctx context.Context, opt *Start) error

Start runs the docker compose start command.

func (*Compose) Stats

func (c *Compose) Stats(ctx context.Context, opt *Stats) error

Stats runs the docker compose stats command.

func (*Compose) Stop

func (c *Compose) Stop(ctx context.Context, opt *Stop) error

Stop runs the docker compose stop command.

func (*Compose) Top

func (c *Compose) Top(ctx context.Context, opt *Top) error

Top runs the docker compose top command.

func (*Compose) Unpause

func (c *Compose) Unpause(ctx context.Context, opt *Unpause) error

Unpause runs the docker compose unpause command.

func (*Compose) Up

func (c *Compose) Up(ctx context.Context, opt *Up) error

Up runs the docker compose up command. A nil opt uses defaults (writer is os.Stdout).

func (*Compose) Version

func (c *Compose) Version(ctx context.Context, opt *Version) error

Version runs the docker compose version command.

func (*Compose) Volumes

func (c *Compose) Volumes(ctx context.Context, opt *Volumes) error

Volumes runs the docker compose volumes command.

func (*Compose) Wait

func (c *Compose) Wait(ctx context.Context, opt *Wait) error

Wait runs the docker compose wait command. ServiceNames is required.

func (*Compose) Watch

func (c *Compose) Watch(ctx context.Context, opt *Watch) error

Watch runs the docker compose watch command.

type ComposeAttachError

type ComposeAttachError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeAttachError

func NewComposeAttachError(err error) *ComposeAttachError

func (*ComposeAttachError) Error

func (e *ComposeAttachError) Error() string

func (*ComposeAttachError) Unwrap

func (e *ComposeAttachError) Unwrap() error

type ComposeBuild

type ComposeBuild struct {
	BuildArg         []string // key=value, appended as --build-arg each
	Builder          string
	Check            bool
	Memory           string // e.g. "2G"
	NoCache          bool
	Print            bool
	Provenance       bool
	Pull             bool
	Push             bool
	Quiet            bool
	SBOM             bool
	SSH              []string // e.g. "default" or "key=path"
	WithDependencies bool
	Writer           io.Writer
	Profiles         []string
	ServiceNames     []string
	Flags            []string
}

ComposeBuild is the options for the compose build command

func (*ComposeBuild) GenerateFlags

func (opt *ComposeBuild) GenerateFlags() ([]string, error)

type ComposeBuildError

type ComposeBuildError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeBuildError is the error for the compose build command

func NewComposeBuildError

func NewComposeBuildError(err error) *ComposeBuildError

func (*ComposeBuildError) Error

func (e *ComposeBuildError) Error() string

func (*ComposeBuildError) Unwrap

func (e *ComposeBuildError) Unwrap() error

type ComposeCommitError

type ComposeCommitError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeCommitError

func NewComposeCommitError(err error) *ComposeCommitError

func (*ComposeCommitError) Error

func (e *ComposeCommitError) Error() string

func (*ComposeCommitError) Unwrap

func (e *ComposeCommitError) Unwrap() error

type ComposeConfig

type ComposeConfig struct {
	PrintEnvironment    bool
	Format              string // yaml | json
	Hash                string // service name or "*"
	PrintImages         bool
	LockImageDigests    bool
	PrintModels         bool
	PrintNetworks       bool
	NoConsistency       bool
	NoEnvResolution     bool
	NoInterpolate       bool
	NoNormalize         bool
	NoPathResolution    bool
	Output              string
	PrintProfiles       bool
	Quiet               bool
	ResolveImageDigests bool
	PrintServices       bool
	PrintVariables      bool
	PrintVolumes        bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

ComposeConfig is the options for the compose config command. Named ComposeConfig because Config is too generic (MergedConfig, container.Config).

func (*ComposeConfig) GenerateFlags

func (opt *ComposeConfig) GenerateFlags() ([]string, error)

type ComposeConfigError

type ComposeConfigError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeConfigError

func NewComposeConfigError(err error) *ComposeConfigError

func (*ComposeConfigError) Error

func (e *ComposeConfigError) Error() string

func (*ComposeConfigError) Unwrap

func (e *ComposeConfigError) Unwrap() error

type ComposeCpError

type ComposeCpError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeCpError

func NewComposeCpError(err error) *ComposeCpError

func (*ComposeCpError) Error

func (e *ComposeCpError) Error() string

func (*ComposeCpError) Unwrap

func (e *ComposeCpError) Unwrap() error

type ComposeCreateError

type ComposeCreateError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeCreateError

func NewComposeCreateError(err error) *ComposeCreateError

func (*ComposeCreateError) Error

func (e *ComposeCreateError) Error() string

func (*ComposeCreateError) Unwrap

func (e *ComposeCreateError) Unwrap() error

type ComposeDownError

type ComposeDownError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeDownError is the error for the compose down command

func NewComposeDownError

func NewComposeDownError(err error) *ComposeDownError

NewComposeDownError creates a new ComposeDownError wrapping err.

func (*ComposeDownError) Error

func (e *ComposeDownError) Error() string

func (*ComposeDownError) Unwrap

func (e *ComposeDownError) Unwrap() error

type ComposeError

type ComposeError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeError is the error for the compose command

func NewComposeError

func NewComposeError(err error) *ComposeError

func (*ComposeError) Error

func (e *ComposeError) Error() string

func (*ComposeError) Unwrap

func (e *ComposeError) Unwrap() error

type ComposeEventsError

type ComposeEventsError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeEventsError is the error for the compose events command

func NewComposeEventsError

func NewComposeEventsError(err error) *ComposeEventsError

NewComposeEventsError creates a new ComposeEventsError wrapping err.

func (*ComposeEventsError) Error

func (e *ComposeEventsError) Error() string

func (*ComposeEventsError) Unwrap

func (e *ComposeEventsError) Unwrap() error

type ComposeExecError

type ComposeExecError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeExecError is the error for the compose exec command

func NewComposeExecError

func NewComposeExecError(err error) *ComposeExecError

func (*ComposeExecError) Error

func (e *ComposeExecError) Error() string

func (*ComposeExecError) Unwrap

func (e *ComposeExecError) Unwrap() error

type ComposeExport

type ComposeExport struct {
	Index  *int
	Output string

	Writer   io.Writer
	Profiles []string
	Flags    []string
	Service  string // required
}

ComposeExport is the options for the compose export command. Named ComposeExport to avoid confusion with Project.Export. Service is required.

func (*ComposeExport) GenerateFlags

func (opt *ComposeExport) GenerateFlags() ([]string, error)

type ComposeExportError

type ComposeExportError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeExportError

func NewComposeExportError(err error) *ComposeExportError

func (*ComposeExportError) Error

func (e *ComposeExportError) Error() string

func (*ComposeExportError) Unwrap

func (e *ComposeExportError) Unwrap() error

type ComposeFlagError

type ComposeFlagError struct {
	Flag    string
	Message string
}

ComposeFlagError is the error for the compose flag

func NewComposeFlagError

func NewComposeFlagError(flag, message string) *ComposeFlagError

NewComposeFlagError makes a new ComposeFlagError with the given flag and message.

func (*ComposeFlagError) Error

func (e *ComposeFlagError) Error() string

func (*ComposeFlagError) Unwrap

func (e *ComposeFlagError) Unwrap() error

type ComposeImagesError

type ComposeImagesError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeImagesError

func NewComposeImagesError(err error) *ComposeImagesError

func (*ComposeImagesError) Error

func (e *ComposeImagesError) Error() string

func (*ComposeImagesError) Unwrap

func (e *ComposeImagesError) Unwrap() error

type ComposeKillError

type ComposeKillError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeKillError is the error for the compose kill command

func NewComposeKillError

func NewComposeKillError(err error) *ComposeKillError

NewComposeKillError creates a new ComposeKillError wrapping err.

func (*ComposeKillError) Error

func (e *ComposeKillError) Error() string

func (*ComposeKillError) Unwrap

func (e *ComposeKillError) Unwrap() error

type ComposeLogsError

type ComposeLogsError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeLogsError is the error for the compose logs command

func NewComposeLogsError

func NewComposeLogsError(err error) *ComposeLogsError

NewComposeLogsError creates a new ComposeLogsError wrapping err.

func (*ComposeLogsError) Error

func (e *ComposeLogsError) Error() string

func (*ComposeLogsError) Unwrap

func (e *ComposeLogsError) Unwrap() error

type ComposeLsError

type ComposeLsError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeLsError

func NewComposeLsError(err error) *ComposeLsError

func (*ComposeLsError) Error

func (e *ComposeLsError) Error() string

func (*ComposeLsError) Unwrap

func (e *ComposeLsError) Unwrap() error

type ComposePauseError

type ComposePauseError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposePauseError

func NewComposePauseError(err error) *ComposePauseError

func (*ComposePauseError) Error

func (e *ComposePauseError) Error() string

func (*ComposePauseError) Unwrap

func (e *ComposePauseError) Unwrap() error

type ComposePortError

type ComposePortError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposePortError

func NewComposePortError(err error) *ComposePortError

func (*ComposePortError) Error

func (e *ComposePortError) Error() string

func (*ComposePortError) Unwrap

func (e *ComposePortError) Unwrap() error

type ComposePsError

type ComposePsError struct {
	Message string
	// contains filtered or unexported fields
}

ComposePsError is the error for the compose ps command

func NewComposePsError

func NewComposePsError(err error) *ComposePsError

func (*ComposePsError) Error

func (e *ComposePsError) Error() string

func (*ComposePsError) Unwrap

func (e *ComposePsError) Unwrap() error

type ComposePublishError

type ComposePublishError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposePublishError

func NewComposePublishError(err error) *ComposePublishError

func (*ComposePublishError) Error

func (e *ComposePublishError) Error() string

func (*ComposePublishError) Unwrap

func (e *ComposePublishError) Unwrap() error

type ComposePullError

type ComposePullError struct {
	Message string
	// contains filtered or unexported fields
}

ComposePullError is the error for the compose pull command

func NewComposePullError

func NewComposePullError(err error) *ComposePullError

func (*ComposePullError) Error

func (e *ComposePullError) Error() string

func (*ComposePullError) Unwrap

func (e *ComposePullError) Unwrap() error

type ComposePushError

type ComposePushError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposePushError

func NewComposePushError(err error) *ComposePushError

func (*ComposePushError) Error

func (e *ComposePushError) Error() string

func (*ComposePushError) Unwrap

func (e *ComposePushError) Unwrap() error

type ComposeRestartError

type ComposeRestartError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeRestartError is the error for the compose restart command

func NewComposeRestartError

func NewComposeRestartError(err error) *ComposeRestartError

func (*ComposeRestartError) Error

func (e *ComposeRestartError) Error() string

func (*ComposeRestartError) Unwrap

func (e *ComposeRestartError) Unwrap() error

type ComposeRmError

type ComposeRmError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeRmError

func NewComposeRmError(err error) *ComposeRmError

func (*ComposeRmError) Error

func (e *ComposeRmError) Error() string

func (*ComposeRmError) Unwrap

func (e *ComposeRmError) Unwrap() error

type ComposeRunError

type ComposeRunError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeRunError

func NewComposeRunError(err error) *ComposeRunError

func (*ComposeRunError) Error

func (e *ComposeRunError) Error() string

func (*ComposeRunError) Unwrap

func (e *ComposeRunError) Unwrap() error

type ComposeScaleError

type ComposeScaleError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeScaleError

func NewComposeScaleError(err error) *ComposeScaleError

func (*ComposeScaleError) Error

func (e *ComposeScaleError) Error() string

func (*ComposeScaleError) Unwrap

func (e *ComposeScaleError) Unwrap() error

type ComposeStartError

type ComposeStartError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeStartError is the error for the compose start command

func NewComposeStartError

func NewComposeStartError(err error) *ComposeStartError

func (*ComposeStartError) Error

func (e *ComposeStartError) Error() string

func (*ComposeStartError) Unwrap

func (e *ComposeStartError) Unwrap() error

type ComposeStatsError

type ComposeStatsError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeStatsError

func NewComposeStatsError(err error) *ComposeStatsError

func (*ComposeStatsError) Error

func (e *ComposeStatsError) Error() string

func (*ComposeStatsError) Unwrap

func (e *ComposeStatsError) Unwrap() error

type ComposeStopError

type ComposeStopError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeStopError is the error for the compose stop command

func NewComposeStopError

func NewComposeStopError(err error) *ComposeStopError

func (*ComposeStopError) Error

func (e *ComposeStopError) Error() string

func (*ComposeStopError) Unwrap

func (e *ComposeStopError) Unwrap() error

type ComposeTopError

type ComposeTopError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeTopError

func NewComposeTopError(err error) *ComposeTopError

func (*ComposeTopError) Error

func (e *ComposeTopError) Error() string

func (*ComposeTopError) Unwrap

func (e *ComposeTopError) Unwrap() error

type ComposeUnpauseError

type ComposeUnpauseError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeUnpauseError

func NewComposeUnpauseError(err error) *ComposeUnpauseError

func (*ComposeUnpauseError) Error

func (e *ComposeUnpauseError) Error() string

func (*ComposeUnpauseError) Unwrap

func (e *ComposeUnpauseError) Unwrap() error

type ComposeUpError

type ComposeUpError struct {
	Message string
	// contains filtered or unexported fields
}

ComposeUpError is the error for the compose up command

func NewComposeUpError

func NewComposeUpError(err error) *ComposeUpError

NewComposeUpError creates a new ComposeUpError wrapping err.

func (*ComposeUpError) Error

func (e *ComposeUpError) Error() string

func (*ComposeUpError) Unwrap

func (e *ComposeUpError) Unwrap() error

type ComposeVersionError

type ComposeVersionError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeVersionError

func NewComposeVersionError(err error) *ComposeVersionError

func (*ComposeVersionError) Error

func (e *ComposeVersionError) Error() string

func (*ComposeVersionError) Unwrap

func (e *ComposeVersionError) Unwrap() error

type ComposeVolumesError

type ComposeVolumesError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeVolumesError

func NewComposeVolumesError(err error) *ComposeVolumesError

func (*ComposeVolumesError) Error

func (e *ComposeVolumesError) Error() string

func (*ComposeVolumesError) Unwrap

func (e *ComposeVolumesError) Unwrap() error

type ComposeWaitError

type ComposeWaitError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeWaitError

func NewComposeWaitError(err error) *ComposeWaitError

func (*ComposeWaitError) Error

func (e *ComposeWaitError) Error() string

func (*ComposeWaitError) Unwrap

func (e *ComposeWaitError) Unwrap() error

type ComposeWatchError

type ComposeWatchError struct {
	Message string
	// contains filtered or unexported fields
}

func NewComposeWatchError

func NewComposeWatchError(err error) *ComposeWatchError

func (*ComposeWatchError) Error

func (e *ComposeWatchError) Error() string

func (*ComposeWatchError) Unwrap

func (e *ComposeWatchError) Unwrap() error

type Container

type Container struct {
	Name   string        // the name of the container
	Config *MergedConfig // merged docker sdk configuration for container creation
	Errors []error
}

func NewContainer

func NewContainer(name ...string) *Container

NewContainer creates a new container with the given name. It will return a container with empty configurations ready to be set. a container is a wrapper around the docker sdk container configuration. but it can be used as a service config in a compose project

parameters:

  • name: the name of the container

Note: 'name' is optional when using this container as a Compose service config. It is required when using the Docker SDK directly. If multiple strings are passed as the name, they will be joined with hyphens (e.g., "foo", "bar" -> "foo-bar").

func (*Container) AddedCapabilities

func (c *Container) AddedCapabilities(caps ...Capability) *Container

func (*Container) AddedDevice

func (c *Container) AddedDevice(device string, pathInContainer string, permissions string) *Container

func (*Container) AddedGroups

func (c *Container) AddedGroups(group ...string) *Container

func (*Container) Apply

func (c *Container) Apply(fns ...Mutator) *Container

Apply applies mutators to the container and returns it.

func (*Container) Architecture

func (c *Container) Architecture(architecture string) *Container

func (*Container) AttachedStderr

func (c *Container) AttachedStderr() *Container

func (*Container) AttachedStdin

func (c *Container) AttachedStdin() *Container

func (*Container) AttachedStdout

func (c *Container) AttachedStdout() *Container

func (*Container) AutoRemove

func (c *Container) AutoRemove() *Container

func (*Container) BindMountWithPropagation

func (c *Container) BindMountWithPropagation(source, target string, propagation MountPropagation) *Container

func (*Container) BlkioDeviceReadBps

func (c *Container) BlkioDeviceReadBps(devicePath string, rate int) *Container

func (*Container) BlkioDeviceReadBpsString

func (c *Container) BlkioDeviceReadBpsString(devicePath, rate string) *Container

func (*Container) BlkioDeviceReadIOps

func (c *Container) BlkioDeviceReadIOps(devicePath string, rate uint64) *Container

func (*Container) BlkioDeviceWriteBps

func (c *Container) BlkioDeviceWriteBps(devicePath string, rate int) *Container

func (*Container) BlkioDeviceWriteBpsString

func (c *Container) BlkioDeviceWriteBpsString(devicePath, rate string) *Container

func (*Container) BlkioDeviceWriteIOps

func (c *Container) BlkioDeviceWriteIOps(devicePath string, rate uint64) *Container

func (*Container) BlkioWeight

func (c *Container) BlkioWeight(weight uint16) *Container

func (*Container) CPUCount

func (c *Container) CPUCount(count int64) *Container

func (*Container) CPUPercent

func (c *Container) CPUPercent(percent int64) *Container

func (*Container) CPUPeriod

func (c *Container) CPUPeriod(period int) *Container

func (*Container) CPUPeriodString

func (c *Container) CPUPeriodString(period string) *Container

func (*Container) CPUQuota

func (c *Container) CPUQuota(quota int) *Container

func (*Container) CPUQuotaString

func (c *Container) CPUQuotaString(quota string) *Container

func (*Container) CPURealtimePeriod

func (c *Container) CPURealtimePeriod(period int) *Container

func (*Container) CPURealtimePeriodString

func (c *Container) CPURealtimePeriodString(period string) *Container

func (*Container) CPURealtimeRuntime

func (c *Container) CPURealtimeRuntime(runtime int64) *Container

func (*Container) CPUShares

func (c *Container) CPUShares(shares int64) *Container

func (*Container) Cgroup

func (c *Container) Cgroup(cgroup string) *Container

func (*Container) CgroupParent

func (c *Container) CgroupParent(parent string) *Container

func (*Container) Command

func (c *Container) Command(cmd ...string) *Container

func (*Container) ConsoleSize

func (c *Container) ConsoleSize(height uint, width uint) *Container

func (*Container) ContainerIDFile

func (c *Container) ContainerIDFile(path string) *Container

func (*Container) CpusetCpus

func (c *Container) CpusetCpus(cpus string) *Container

func (*Container) CpusetMems

func (c *Container) CpusetMems(mems string) *Container

func (*Container) DNSLookups

func (c *Container) DNSLookups(dns ...string) *Container

func (*Container) DNSOptions

func (c *Container) DNSOptions(dnsOption ...string) *Container

func (*Container) DNSSearches

func (c *Container) DNSSearches(search ...string) *Container

func (*Container) DeviceCgroupRules

func (c *Container) DeviceCgroupRules(rules ...string) *Container

func (*Container) DeviceRequest

func (c *Container) DeviceRequest(driver string, count int, deviceIDs []string, capabilities [][]string) *Container

func (*Container) DisabledHealthCheck

func (c *Container) DisabledHealthCheck() *Container

DisabledHealthCheck disables the healthcheck.

func (*Container) DisabledNetwork

func (c *Container) DisabledNetwork() *Container

func (*Container) DomainName

func (c *Container) DomainName(domainname string) *Container

func (*Container) DroppedAllCapabilities

func (c *Container) DroppedAllCapabilities() *Container

func (*Container) DroppedCapabilities

func (c *Container) DroppedCapabilities(caps ...Capability) *Container

func (*Container) DroppedSensitiveCapabilities

func (c *Container) DroppedSensitiveCapabilities() *Container

func (*Container) Endpoint

func (c *Container) Endpoint(name string, opts ...EndpointOpts) *Container

Endpoint joins the named network. Optional EndpointOpts customize the endpoint.

func (*Container) Entrypoint

func (c *Container) Entrypoint(entrypoint ...string) *Container

func (*Container) Env

func (c *Container) Env(key string, value string) *Container

func (*Container) EnvMap

func (c *Container) EnvMap(env map[string]string) *Container

func (*Container) EscapedArgs

func (c *Container) EscapedArgs() *Container

func (*Container) ExposedPort

func (c *Container) ExposedPort(protocol string, port string) *Container

func (*Container) ExtraHost

func (c *Container) ExtraHost(extraHosts ...string) *Container

func (*Container) HealthCheck

func (c *Container) HealthCheck(h Health) *Container

HealthCheck sets the container healthcheck from a Health value.

func (*Container) HostBindMountRecursiveRO

func (c *Container) HostBindMountRecursiveRO(source, target string) *Container

func (*Container) HostName

func (c *Container) HostName(hostname string) *Container

func (*Container) Image

func (c *Container) Image(image string) *Container

func (*Container) Imagef

func (c *Container) Imagef(stringFormat string, args ...any) *Container

func (*Container) Init

func (c *Container) Init() *Container

func (*Container) IpcMode

func (c *Container) IpcMode(mode string) *Container

func (*Container) Isolation

func (c *Container) Isolation(isolation string) *Container

func (*Container) KernelMemory

func (c *Container) KernelMemory(memory int) *Container

func (*Container) KernelMemoryString

func (c *Container) KernelMemoryString(memory string) *Container

func (*Container) Label

func (c *Container) Label(label, value string) *Container

func (*Container) LogDriver

func (c *Container) LogDriver(driver string, options map[string]string) *Container

func (*Container) MaskedPaths

func (c *Container) MaskedPaths(paths ...string) *Container

func (*Container) MemoryLimit

func (c *Container) MemoryLimit(memory int) *Container

func (*Container) MemoryLimitString

func (c *Container) MemoryLimitString(memory string) *Container

func (*Container) MemoryReservation

func (c *Container) MemoryReservation(memory int) *Container

func (*Container) MemoryReservationString

func (c *Container) MemoryReservationString(memory string) *Container

func (*Container) MemorySwap

func (c *Container) MemorySwap(memorySwap int) *Container

func (*Container) MemorySwapString

func (c *Container) MemorySwapString(memorySwap string) *Container

func (*Container) MemorySwappiness

func (c *Container) MemorySwappiness(swappiness int64) *Container

func (*Container) Mount

func (c *Container) Mount(m Mount) *Container

Mount adds a host mount point.

func (*Container) NetworkMode

func (c *Container) NetworkMode(mode string) *Container

func (*Container) NonRecursiveBindMount

func (c *Container) NonRecursiveBindMount(source, target string, readonly bool) *Container

func (*Container) OS

func (c *Container) OS(OS string) *Container

func (*Container) OSFeatures

func (c *Container) OSFeatures(OSFeatures ...string) *Container

func (*Container) OSVersion

func (c *Container) OSVersion(OSVersion string) *Container

func (*Container) OnBuild

func (c *Container) OnBuild(args ...string) *Container

func (*Container) OomKillDisable

func (c *Container) OomKillDisable() *Container

func (*Container) OomScoreAdj

func (c *Container) OomScoreAdj(score int) *Container

func (*Container) PidMode

func (c *Container) PidMode(mode string) *Container

func (*Container) PidsLimit

func (c *Container) PidsLimit(limit int64) *Container

func (*Container) PortBindings

func (c *Container) PortBindings(protocol, hostIP, hostPort, containerPort string) *Container

func (*Container) Privileged

func (c *Container) Privileged() *Container

func (*Container) PublishAllPorts

func (c *Container) PublishAllPorts() *Container

func (*Container) ROHostBindMount

func (c *Container) ROHostBindMount(source string, target string) *Container

func (*Container) RONamedVolumeMount

func (c *Container) RONamedVolumeMount(name, target string) *Container

func (*Container) RWHostBindMount

func (c *Container) RWHostBindMount(source string, target string) *Container

func (*Container) RWNamedVolumeMount

func (c *Container) RWNamedVolumeMount(name, target string) *Container

func (*Container) RWNamedVolumeMountWithLabel

func (c *Container) RWNamedVolumeMountWithLabel(name, target, labelKey, labelValue string) *Container

func (*Container) RWNamedVolumeSubPath

func (c *Container) RWNamedVolumeSubPath(name, target, subPath string) *Container

func (*Container) ReadOnlyRootfs

func (c *Container) ReadOnlyRootfs() *Container

func (*Container) ReadonlyPaths

func (c *Container) ReadonlyPaths(paths ...string) *Container

func (*Container) RestartAlways

func (c *Container) RestartAlways() *Container

func (*Container) RestartPolicy

func (c *Container) RestartPolicy(mode RestartPolicy, maxRetryCount int) *Container

func (*Container) RestartPolicyAlways

func (c *Container) RestartPolicyAlways() *Container

func (*Container) RestartPolicyNever

func (c *Container) RestartPolicyNever() *Container

func (*Container) RestartPolicyOnFailure

func (c *Container) RestartPolicyOnFailure(maxRetryCount int) *Container

func (*Container) RestartPolicyUnlessStopped

func (c *Container) RestartPolicyUnlessStopped() *Container

func (*Container) RestartUnlessStopped

func (c *Container) RestartUnlessStopped() *Container

RestartUnlessStopped is an alias for RestartPolicyUnlessStopped.

func (*Container) Runtime

func (c *Container) Runtime(runtime string) *Container

func (*Container) SecurityOpts

func (c *Container) SecurityOpts(opts ...string) *Container

func (*Container) Shell

func (c *Container) Shell(shell ...string) *Container

func (*Container) ShmSize

func (c *Container) ShmSize(size int) *Container

func (*Container) ShmSizeString

func (c *Container) ShmSizeString(size string) *Container

func (*Container) StdinOnce

func (c *Container) StdinOnce() *Container

func (*Container) StdinOpen

func (c *Container) StdinOpen() *Container

func (*Container) StopSignal

func (c *Container) StopSignal(signal string) *Container

func (*Container) StopTimeout

func (c *Container) StopTimeout(timeout int) *Container

func (*Container) StorageOpt

func (c *Container) StorageOpt(key, value string) *Container

func (*Container) Sysctls

func (c *Container) Sysctls(key, value string) *Container

func (*Container) Tmpfs

func (c *Container) Tmpfs(key, value string) *Container

func (*Container) TmpfsMount

func (c *Container) TmpfsMount(target string, sizeBytes int, mode os.FileMode) *Container

func (*Container) TmpfsMountCustomOptions

func (c *Container) TmpfsMountCustomOptions(target string, sizeBytes int, flags ...[]string) *Container

func (*Container) TmpfsMountExec

func (c *Container) TmpfsMountExec(target string, sizeBytes int) *Container

func (*Container) TmpfsMountUIDGID

func (c *Container) TmpfsMountUIDGID(target string, sizeBytes int, uid, gid string) *Container

func (*Container) Tty

func (c *Container) Tty() *Container

func (*Container) UTSMode

func (c *Container) UTSMode(mode string) *Container

func (*Container) Ulimits

func (c *Container) Ulimits(name string, soft, hard int64) *Container

func (*Container) User

func (c *Container) User(user string) *Container

func (*Container) UserNSMode

func (c *Container) UserNSMode(mode string) *Container

func (*Container) Validate

func (c *Container) Validate() error

Validate validates the container config. It will return an error if the container has errors.

func (*Container) Variant

func (c *Container) Variant(variant string) *Container

func (*Container) Volume

func (c *Container) Volume(volume string) *Container

func (*Container) VolumeBinds

func (c *Container) VolumeBinds(binds ...string) *Container

func (*Container) VolumeDriver

func (c *Container) VolumeDriver(driver string) *Container

func (*Container) VolumesFrom

func (c *Container) VolumesFrom(from string) *Container

func (*Container) With

func (c *Container) With(setters ...any) *Container

With sets the container config via the setter functions. It will return a container with the container config set. If any of the setters return an error, the error will be appended to the container's error slice.

parameters:

  • setters: the setters to set the container config

note: setters can be any type that implements the SetContainerConfig, SetHostConfig, SetNetworkConfig, or SetPlatformConfig function type. If a setter is nil, it will be skipped.

func (*Container) WithContainerConfig

func (c *Container) WithContainerConfig(setters ...SetContainerConfig) *Container

WithContainerConfig sets the container config via the setter functions. It will return a container with the container config set. If any of the setters return an error, the error will be appended to the container's error slice. parameters:

  • setters: the setters to set the container config

func (*Container) WithHostConfig

func (c *Container) WithHostConfig(setters ...SetHostConfig) *Container

WithHostConfig sets the host config via the setter functions. It will return a container with the host config set. If any of the setters return an error, the error will be appended to the container's error slice.

parameters:

  • setters: the setters to set the host config

func (*Container) WithNetworkConfig

func (c *Container) WithNetworkConfig(setters ...SetNetworkConfig) *Container

WithNetworkConfig sets the network config via the setter functions. It will return a container with the network config set. If any of the setters return an error, the error will be appended to the container's error slice.

parameters:

  • setters: the setters to set the network config

func (*Container) WithPlatformConfig

func (c *Container) WithPlatformConfig(setters ...SetPlatformConfig) *Container

WithPlatformConfig sets the platform config via the setter functions. It will return a container with the platform config set. If any of the setters return an error, the error will be appended to the container's error slice. parameters:

  • setters: the setters to set the platform config

func (*Container) WorkingDir

func (c *Container) WorkingDir(dir string) *Container

type Cp

type Cp struct {
	All        bool
	Archive    bool
	FollowLink bool
	Index      *int

	Writer   io.Writer
	Stdin    io.Reader // used when Source or Dest is "-"
	Profiles []string
	Flags    []string
	Source   string // required
	Dest     string // required
}

Cp is the options for the compose cp command. Source and Dest are required (SERVICE:PATH or PATH or "-").

func (*Cp) GenerateFlags

func (opt *Cp) GenerateFlags() ([]string, error)

type Create

type Create struct {
	Build         bool
	ForceRecreate bool
	NoBuild       bool
	NoRecreate    bool
	Pull          string
	QuietPull     bool
	RemoveOrphans bool
	Scale         []UpScale
	Yes           bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Create is the options for the compose create command.

func (*Create) GenerateFlags

func (opt *Create) GenerateFlags() ([]string, error)

type Deploy

type Deploy struct {
	Mode         string
	Replicas     *int
	Labels       map[string]string
	Limits       *Resources
	Reservations *Resources
}

Deploy is Compose deploy configuration.

type Down

type Down struct {
	RemoveOrphans bool
	Timeout       *int
	RemoveImage   *string
	RemoveVolumes bool

	Flags        []string
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
}

Down is the options for the compose down command

func (*Down) GenerateFlags

func (opt *Down) GenerateFlags() ([]string, error)

type EndpointOpts

type EndpointOpts struct {
	Aliases       []string
	Links         []string
	MacAddress    string
	DriverOptions map[string]string
	IPv4          string
	IPv6          string
	LinkLocalIPs  []string
}

EndpointOpts are optional settings for a network endpoint.

type Events

type Events struct {
	// Core event fields
	Time    string `json:"time"`
	Type    string `json:"type"`
	Action  string `json:"action"`
	ID      string `json:"id"`
	Service string `json:"service"`
	// Attributes map containing event-specific information
	Attributes map[string]string `json:"attributes"`

	// Additional fields that may be present in some events
	Scope  string `json:"scope,omitempty"`
	Status string `json:"status,omitempty"`
	From   string `json:"from,omitempty"`
}

type Exec

type Exec struct {
	Detach     bool
	Env        []string // key=value, passed as -e each
	Index      *int     // --index for multi-replica services
	NoTTY      bool     // -T: disable TTY
	Privileged bool
	User       string // -u
	Workdir    string // -w
	Writer     io.Writer
	Stdin      io.Reader // optional; forwarded to the container after compose file is read
	Profiles   []string
	Service    string   // required: service name
	Command    []string // required: command and args (e.g. ["sh", "-c", "echo hi"])
}

Exec is the options for the compose exec command. Usage: docker compose exec [OPTIONS] SERVICE COMMAND [ARGS...] Service and Command are required; set via WithService and WithCommand.

func (*Exec) GenerateFlags

func (opt *Exec) GenerateFlags() ([]string, error)

type Health

type Health struct {
	Test         []string
	Timeout      int
	Interval     int
	StartPeriod  int
	Retries      int
	TimeoutD     string
	IntervalD    string
	StartPeriodD string
}

Health is a container healthcheck. Timeout/Interval/StartPeriod are seconds unless the matching *D field is a duration string ("2s", "1m").

type IPAMPool

type IPAMPool struct {
	Subnet             string
	Gateway            string
	IPRange            string
	AuxiliaryAddresses map[string]string
}

IPAMPool is a project network IPAM pool.

type Images

type Images struct {
	Format string // table | json
	Quiet  bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Images is the options for the compose images command.

func (*Images) GenerateFlags

func (opt *Images) GenerateFlags() ([]string, error)

type Kill

type Kill struct {
	Signal        *string
	RemoveOrphans bool

	Flags        []string
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
}

Kill is the options for the compose kill command

func (*Kill) GenerateFlags

func (opt *Kill) GenerateFlags() ([]string, error)

GenerateFlags generates the flags for the compose kill command

It will return a slice of flags to append to the command Eg.

[]string{"kill", "--signal", "SIGKILL", "--remove-orphans"}

type Logs

type Logs struct {
	Tail        *int
	Follow      bool
	NoLogPrefix bool

	Writer       io.Writer
	Flags        []string
	Profiles     []string
	ServiceNames []string
}

Logs is the options for the compose logs command

func (*Logs) GenerateFlags

func (opt *Logs) GenerateFlags() ([]string, error)

type Ls

type Ls struct {
	All    bool
	Filter []string
	Format string
	Quiet  bool

	Writer   io.Writer
	Profiles []string
	Flags    []string
}

Ls is the options for the compose ls command (lists Compose projects on the engine).

func (*Ls) GenerateFlags

func (opt *Ls) GenerateFlags() ([]string, error)

type MergedConfig

type MergedConfig struct {
	Container *container.Config         // the container configuration
	Host      *container.HostConfig     // the host configuration
	Network   *network.NetworkingConfig // the network configuration
	Platform  *ocispec.Platform         // the platform configuration
}

type Mount

type Mount struct {
	Source   string
	Target   string
	Type     MountType
	ReadOnly bool
}

Mount describes a single host mount point.

type MountPropagation

type MountPropagation = mount.Propagation

MountPropagation is a bind-mount propagation mode.

type MountType

type MountType = mount.MountType

MountType is a volume/bind/tmpfs mount type.

type Mutator

type Mutator func(*Container)

Mutator mutates a container. Used with Apply / WhenTrue / Group.

func Each

func Each[T any](items []T, f func(i int, t T) Mutator) Mutator

func Group

func Group(fns ...Mutator) Mutator

func OnlyIf

func OnlyIf(check CheckClosure, f Mutator) Mutator

func WhenTrue

func WhenTrue(check bool, fns ...Mutator) Mutator

func WhenTrueElse

func WhenTrueElse(check bool, fn, elseFn Mutator) Mutator

func WhenTrueElseFn

func WhenTrueElseFn(predicate PredicateClosure, fn, elseFn Mutator) Mutator

func WhenTrueFn

func WhenTrueFn(predicate PredicateClosure, fns ...Mutator) Mutator

type Pause

type Pause struct {
	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Pause is the options for the compose pause command.

func (*Pause) GenerateFlags

func (opt *Pause) GenerateFlags() ([]string, error)

type Port

type Port struct {
	Index    *int
	Protocol string // tcp | udp

	Writer      io.Writer
	Profiles    []string
	Flags       []string
	Service     string // required
	PrivatePort int    // required
}

Port is the options for the compose port command. Service and PrivatePort are required.

func (*Port) GenerateFlags

func (opt *Port) GenerateFlags() ([]string, error)

type PredicateClosure

type PredicateClosure func() bool

type Project

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

Project is a wrapper around types.Project It provides methods to create and manage a docker Compose project.

func NewProject

func NewProject(name string) *Project

NewProject creates a new project with the given name. It initializes the project with an empty service list. The name is used as the project name in the compose file.

func (*Project) Export

func (p *Project) Export(file string, perm os.FileMode) error

Export exports the project to a file parameters:

  • file: the file path to export the project to
  • perm: the permission of the file

func (*Project) ForEachService

func (p *Project) ForEachService(fn func(name string, service *types.ServiceConfig) error) error

ForEachService iterates over each service in the project and calls the provided function to provide the ability to mutate a service parameters:

  • fn: the function to call for each service

returns an error if the function returns an error

func (*Project) GetService

func (p *Project) GetService(name string) (*types.ServiceConfig, error)

GetService returns a service from the project parameters:

  • name: the name of the service

returns the service and an error if the service is not found or the project has no services

func (*Project) Marshal

func (p *Project) Marshal() ([]byte, error)

Marshal marshals the project to a yaml bytes slice

func (*Project) Unwrap

func (p *Project) Unwrap() *types.Project

Unwrap returns the underlying types.Project

func (*Project) Validate

func (p *Project) Validate() error

Validate validates the project returns an error if the project has errors

func (*Project) WithNetwork

func (p *Project) WithNetwork(name string, spec ...ProjectNetwork) *Project

WithNetwork defines a new network in the project

func (*Project) WithSecret

func (p *Project) WithSecret(key string, spec ...ProjectSecret) *Project

WithSecret defines a new secret in the project

func (*Project) WithService

func (p *Project) WithService(name string, service *Container, extras ...any) *Project

WithService defines a new service in the project parameters:

  • name: the name of the service
  • service: the container to create the service from
  • setters: the setters to apply to the service

func (*Project) WithVolume

func (p *Project) WithVolume(name string, spec ...ProjectVolume) *Project

WithVolume defines a new volume in the project parameters:

  • name: the name of the volume
  • volume: the volume to create the volume from

type ProjectNetwork

type ProjectNetwork struct {
	Driver        string
	DriverOptions map[string]string
	Internal      bool
	Attachable    bool
	EnableIPv6    bool
	Labels        map[string]string
	IPAMDriver    string
	IPAMPools     []IPAMPool
}

ProjectNetwork is extra config for Project.WithNetwork.

type ProjectSecret

type ProjectSecret struct {
	Name           string
	File           string
	Content        string
	Environment    string
	External       bool
	Driver         string
	DriverOptions  map[string]string
	TemplateDriver string
}

ProjectSecret is extra config for Project.WithSecret.

type ProjectVolume

type ProjectVolume struct {
	Driver        string
	DriverOptions map[string]string
	Labels        map[string]string
}

ProjectVolume is extra config for Project.WithVolume.

type Ps

type Ps struct {
	All          bool
	Filter       []string // e.g. "status=running"
	Format       string
	NoTrunc      bool
	Orphans      *bool // nil = default (true); false = --no-orphans
	Quiet        bool
	Services     bool // --services: display services
	Status       string
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
	Flags        []string
}

Ps is the options for the compose ps command

func (*Ps) GenerateFlags

func (opt *Ps) GenerateFlags() ([]string, error)

type Publish

type Publish struct {
	App                 bool
	OCIVersion          string
	ResolveImageDigests bool
	WithEnv             bool
	Yes                 bool

	Writer     io.Writer
	Profiles   []string
	Flags      []string
	Repository string // required REPOSITORY[:TAG]
}

Publish is the options for the compose publish command. Repository is required.

func (*Publish) GenerateFlags

func (opt *Publish) GenerateFlags() ([]string, error)

type Pull

type Pull struct {
	IgnoreBuildable    bool
	IgnorePullFailures bool
	IncludeDeps        bool
	Policy             string // e.g. "missing", "always", "never"
	Quiet              bool
	Writer             io.Writer
	Profiles           []string
	ServiceNames       []string
	Flags              []string
}

Pull is the options for the compose pull command

func (*Pull) GenerateFlags

func (opt *Pull) GenerateFlags() ([]string, error)

type Push

type Push struct {
	IgnorePushFailures bool
	IncludeDeps        bool
	Quiet              bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Push is the options for the compose push command.

func (*Push) GenerateFlags

func (opt *Push) GenerateFlags() ([]string, error)

type Resources

type Resources struct {
	NanoCPUs    int64
	MemoryBytes uint64
	Pids        int64
}

Resources are deploy resource limits or reservations.

type Restart

type Restart struct {
	NoDeps       bool
	Timeout      *int
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
	Flags        []string
}

Restart is the options for the compose restart command

func (*Restart) GenerateFlags

func (opt *Restart) GenerateFlags() ([]string, error)

type RestartPolicy

type RestartPolicy = hc.RestartPolicy

RestartPolicy is a Docker restart policy name.

type Rm

type Rm struct {
	Force   bool
	Stop    bool
	Volumes bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Rm is the options for the compose rm command.

func (*Rm) GenerateFlags

func (opt *Rm) GenerateFlags() ([]string, error)

type Run

type Run struct {
	Build         bool
	CapAdd        []string
	CapDrop       []string
	Detach        bool
	Entrypoint    string
	Env           []string
	EnvFromFile   []string
	Interactive   *bool // nil = Compose default (true)
	Label         []string
	Name          string
	NoDeps        bool
	NoTTY         bool
	Publish       []string
	Pull          string
	Quiet         bool
	QuietBuild    bool
	QuietPull     bool
	RemoveOrphans bool
	Rm            bool
	ServicePorts  bool
	UseAliases    bool
	User          string
	Volume        []string
	Workdir       string

	Writer   io.Writer
	Stdin    io.Reader
	Profiles []string
	Flags    []string
	Service  string   // required
	Command  []string // optional
}

Run is the options for the compose run command. Service is required. Command is optional (defaults to the service command).

func (*Run) GenerateFlags

func (opt *Run) GenerateFlags() ([]string, error)

type Scale

type Scale struct {
	NoDeps   bool
	Replicas []UpScale

	Writer   io.Writer
	Profiles []string
	Flags    []string
}

Scale is the options for the compose scale command. Replicas is required (at least one SERVICE=NUM).

func (*Scale) GenerateFlags

func (opt *Scale) GenerateFlags() ([]string, error)

type ServiceSecret

type ServiceSecret struct {
	Source string
	Target string
	UID    string
	GID    string
	Mode   *int64
}

ServiceSecret is a service-level secret reference.

type SetContainerConfig

type SetContainerConfig func(config *container.Config) error

SetContainerConfig is a function that sets the container config

type SetHostConfig

type SetHostConfig func(config *container.HostConfig) error

SetHostConfig is a function that sets the host config

type SetNetworkConfig

type SetNetworkConfig func(config *network.NetworkingConfig) error

SetNetworkConfig is a function that sets the network config

type SetPlatformConfig

type SetPlatformConfig func(config *ocispec.Platform) error

SetPlatformConfig is a function that sets the platform config

type SetServiceConfig

type SetServiceConfig func(service *types.ServiceConfig) error

SetServiceConfig is a function that sets the service config

func Annotation

func Annotation(key, value string) SetServiceConfig

Annotation sets a service annotation.

func DependsOn

func DependsOn(service string) SetServiceConfig

DependsOn marks a service as depending on another (condition: started).

func DependsOnHealthy

func DependsOnHealthy(service string) SetServiceConfig

DependsOnHealthy marks a service as depending on another becoming healthy.

func Develop

func Develop(action WatchAction, watchPath, target string, ignorePaths ...string) SetServiceConfig

Develop sets Compose watch/develop config.

func EnvFile

func EnvFile(path string) SetServiceConfig

EnvFile adds a required env file to a service.

func NoAttach

func NoAttach() SetServiceConfig

NoAttach sets attach to false for a service.

func Profiles

func Profiles(profiles ...string) SetServiceConfig

Profiles assigns Compose profiles to a service.

type Start

type Start struct {
	Wait         bool
	WaitTimeout  *int
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
	Flags        []string
}

Start is the options for the compose start command

func (*Start) GenerateFlags

func (opt *Start) GenerateFlags() ([]string, error)

type Stats

type Stats struct {
	All      bool
	Format   string
	NoStream bool
	NoTrunc  bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Stats is the options for the compose stats command.

func (*Stats) GenerateFlags

func (opt *Stats) GenerateFlags() ([]string, error)

type Stop

type Stop struct {
	Timeout      *int
	Writer       io.Writer
	Profiles     []string
	ServiceNames []string
	Flags        []string
}

Stop is the options for the compose stop command

func (*Stop) GenerateFlags

func (opt *Stop) GenerateFlags() ([]string, error)

type Top

type Top struct {
	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Top is the options for the compose top command.

func (*Top) GenerateFlags

func (opt *Top) GenerateFlags() ([]string, error)

type Unpause

type Unpause struct {
	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Unpause is the options for the compose unpause command.

func (*Unpause) GenerateFlags

func (opt *Unpause) GenerateFlags() ([]string, error)

type Up

type Up struct {
	Detach                  bool
	AbortOnContainerExit    bool
	AbortOnContainerFailure bool
	AlwaysRecreateDeps      bool
	Attach                  *string
	AttachDependencies      bool
	Build                   bool
	NoBuild                 bool
	ForceRecreate           bool
	Menu                    bool
	ExitCodeFrom            *string
	NoAttach                *string
	NoColor                 bool
	NoDeps                  bool
	NoLogPrefix             bool
	NoRecreate              bool
	Pull                    *string
	NoStart                 bool
	QuietPull               bool
	RemoveOrphans           bool
	RenewAnonVolumes        bool
	Scale                   []UpScale
	Timeout                 *int
	Timestamps              bool
	Wait                    bool
	WaitTimeout             *int
	Watch                   bool
	Yes                     bool

	Profiles     []string
	Flags        []string
	Writer       io.Writer
	ServiceNames []string
	Errs         []error
}

Up is the options for the compose up command

func (*Up) GenerateFlags

func (opt *Up) GenerateFlags() (flags []string, err error)

GenerateFlags generates the flags for the compose up command

It will return a slice of flags to append to the command Eg.

[]string{"up", "--detach", ...}

type UpScale

type UpScale struct {
	Service string
	Num     int
}

UpScale is the scale for the compose up command

type Version

type Version struct {
	Format string // pretty | json
	Short  bool

	Writer   io.Writer
	Profiles []string
	Flags    []string
}

Version is the options for the compose version command.

func (*Version) GenerateFlags

func (opt *Version) GenerateFlags() ([]string, error)

type Volumes

type Volumes struct {
	Format string
	Quiet  bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Volumes is the options for the compose volumes command.

func (*Volumes) GenerateFlags

func (opt *Volumes) GenerateFlags() ([]string, error)

type Wait

type Wait struct {
	DownProject bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string // required
}

Wait is the options for the compose wait command. ServiceNames is required.

func (*Wait) GenerateFlags

func (opt *Wait) GenerateFlags() ([]string, error)

type Watch

type Watch struct {
	NoUp    bool
	NoPrune bool // --prune=false; Compose defaults to true
	Quiet   bool

	Writer       io.Writer
	Profiles     []string
	Flags        []string
	ServiceNames []string
}

Watch is the options for the compose watch command.

func (*Watch) GenerateFlags

func (opt *Watch) GenerateFlags() ([]string, error)

type WatchAction

type WatchAction string

WatchAction is a Compose develop watch action.

const (
	WatchActionSync        WatchAction = "sync"
	WatchActionRebuild     WatchAction = "rebuild"
	WatchActionSyncRestart WatchAction = "sync+restart"
)

Directories

Path Synopsis
internal
config/cc
Package cc provides the options for the container config.
Package cc provides the options for the container config.
config/hc
Package hc provides the options for the host config.
Package hc provides the options for the host config.
config/hc/mount
Package mount provides the options for the mount config in the host config.
Package mount provides the options for the mount config in the host config.
config/nc
Package nc provides the options for the network config.
Package nc provides the options for the network config.
config/nc/endpoint
Package endpoint provides the options for the endpoint config in the network config.
Package endpoint provides the options for the endpoint config in the network config.
config/nc/endpoint/ipam
Package ipam provides the options for the IPAM config in the endpoint config.
Package ipam provides the options for the IPAM config in the endpoint config.
config/pc
Package pc provides the options for the platform config.
Package pc provides the options for the platform config.
config/sc
Package sc provides functions to set the service config
Package sc provides functions to set the service config
config/sc/build
Package build provides functions to set the build config for a service
Package build provides functions to set the build config for a service
config/sc/build/ulimit
Package ulimit provides a set of functions to configure the ulimits for the build
Package ulimit provides a set of functions to configure the ulimits for the build
config/sc/deploy
Package deploy provides functions to set the deploy configuration for a service
Package deploy provides functions to set the deploy configuration for a service
config/sc/deploy/resource
Package resource provides functions to set the resource configuration for a service deploy
Package resource provides functions to set the resource configuration for a service deploy
config/sc/deploy/resource/device
Package device provides functions to set the device configuration for a service deploys resource
Package device provides functions to set the device configuration for a service deploys resource
config/sc/deploy/update
Package update provides functions to set the update configuration for a service deploy
Package update provides functions to set the update configuration for a service deploy
config/sc/network
Package network provides functions to set the network configuration for a project
Package network provides functions to set the network configuration for a project
config/sc/network/pool
Package pool provides functions to set the ipam pool configuration for a project
Package pool provides functions to set the ipam pool configuration for a project
config/sc/secrets/projectsecret
Package projectsecret provides a set of functions to configure the secret for the project
Package projectsecret provides a set of functions to configure the secret for the project
config/sc/secrets/secretservice
Package secretservice provides a set of functions to configure the secrets for the service
Package secretservice provides a set of functions to configure the secrets for the service
config/sc/volume
Package volume provides functions to set the volume configuration for a project
Package volume provides functions to set the volume configuration for a project

Jump to

Keyboard shortcuts

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