Documentation
¶
Overview ¶
Package kit defines Compose projects and runs them through the Docker Compose SDK.
Package kit provides the container config for the wrapped client. it is built to be created in a declarative way.
Index ¶
- Constants
- type AddOpts
- type Attach
- type BindOptions
- type BridgeConvert
- type BridgeTransformationsCreate
- type BridgeTransformationsList
- type Build
- func (b Build) AdditionalContext(name, value string) Build
- func (b Build) AdditionalContexts(contexts map[string]string) Build
- func (b Build) Apply(cfg *types.ServiceConfig) error
- func (b Build) Arg(key, value string) Build
- func (b Build) Args(args map[string]string) Build
- func (b Build) CacheFrom(sources ...string) Build
- func (b Build) CacheTo(destinations ...string) Build
- func (b Build) Context(path string) Build
- func (b Build) Dockerfile(file DockerFile) Build
- func (b Build) DockerfilePath(path string) Build
- func (b Build) Entitlement(names ...string) Build
- func (b Build) ExtraHost(host string) Build
- func (b Build) Isolation(mode string) Build
- func (b Build) Label(key, value string) Build
- func (b Build) Labels(labels map[string]string) Build
- func (b Build) Network(name string) Build
- func (b Build) NoCache() Build
- func (b Build) NoCacheFilter(filters ...string) Build
- func (b Build) Platform(platforms ...string) Build
- func (b Build) Privileged() Build
- func (b Build) Provenance(mode string) Build
- func (b Build) Pull() Build
- func (b Build) Reader() (io.Reader, error)
- func (b Build) SBOM(mode string) Build
- func (b Build) SSH(id, path string) Build
- func (b Build) Secret(secret BuildSecret) Build
- func (b Build) ShmSize(size int64) Build
- func (b Build) Tag(tags ...string) Build
- func (b Build) Target(name string) Build
- func (b Build) Ulimit(name string, soft, hard int) Build
- type BuildSSH
- type BuildSecret
- type BuildSpec
- type BuildUlimit
- type Commit
- type Compose
- func (c *Compose) Attach(ctx context.Context, opt *Attach) error
- func (c *Compose) BridgeConvert(ctx context.Context, opt *BridgeConvert) error
- func (c *Compose) BridgeTransformationsCreate(ctx context.Context, opt *BridgeTransformationsCreate) error
- func (c *Compose) BridgeTransformationsList(ctx context.Context, opt *BridgeTransformationsList) error
- func (c *Compose) Build(ctx context.Context, opt *ComposeBuild) error
- func (c *Compose) Commit(ctx context.Context, opt *Commit) error
- func (c *Compose) Config(ctx context.Context, opt *ComposeConfig) error
- func (c *Compose) Cp(ctx context.Context, opt *Cp) error
- func (c *Compose) Create(ctx context.Context, opt *Create) error
- func (c *Compose) Down(ctx context.Context, opt *Down) error
- func (c *Compose) Events(ctx context.Context, opt *EventsOpt) (<-chan Events, <-chan error, error)
- func (c *Compose) Exec(ctx context.Context, opt *Exec) error
- func (c *Compose) Export(ctx context.Context, opt *ComposeExport) error
- func (c *Compose) Generate(ctx context.Context, opt *Generate) error
- func (c *Compose) Global(g Global) *Compose
- func (c *Compose) Images(ctx context.Context, opt *Images) error
- func (c *Compose) Kill(ctx context.Context, opt *Kill) error
- func (c *Compose) LoadProject(ctx context.Context, opt *ProjectLoad) (*Project, error)
- func (c *Compose) Logs(ctx context.Context, opt *Logs) error
- func (c *Compose) Ls(ctx context.Context, opt *Ls) error
- func (c *Compose) Pause(ctx context.Context, opt *Pause) error
- func (c *Compose) Port(ctx context.Context, opt *Port) error
- func (c *Compose) Project() *Project
- func (c *Compose) Ps(ctx context.Context, opt *Ps) error
- func (c *Compose) Publish(ctx context.Context, opt *Publish) error
- func (c *Compose) Pull(ctx context.Context, opt *Pull) error
- func (c *Compose) Push(ctx context.Context, opt *Push) error
- func (c *Compose) Restart(ctx context.Context, opt *Restart) error
- func (c *Compose) Rm(ctx context.Context, opt *Rm) error
- func (c *Compose) Run(ctx context.Context, opt *Run) error
- func (c *Compose) Scale(ctx context.Context, opt *Scale) error
- func (c *Compose) Start(ctx context.Context, opt *Start) error
- func (c *Compose) Stats(ctx context.Context, opt *Stats) error
- func (c *Compose) Stop(ctx context.Context, opt *Stop) error
- func (c *Compose) Top(ctx context.Context, opt *Top) error
- func (c *Compose) Unpause(ctx context.Context, opt *Unpause) error
- func (c *Compose) Up(ctx context.Context, opt *Up) error
- func (c *Compose) Version(ctx context.Context, opt *Version) error
- func (c *Compose) Viz(ctx context.Context, opt *Viz) error
- func (c *Compose) Volumes(ctx context.Context, opt *Volumes) error
- func (c *Compose) Wait(ctx context.Context, opt *Wait) error
- func (c *Compose) Watch(ctx context.Context, opt *Watch) error
- type ComposeBuild
- type ComposeConfig
- type ComposeExport
- type Container
- func (c *Container) AddedCapabilities(caps ...types.Capability) *Container
- func (c *Container) AddedDevice(device types.Device) *Container
- func (c *Container) AddedGroups(group ...string) *Container
- func (c *Container) Architecture(architecture string) *Container
- func (c *Container) AttachedStderr() *Container
- func (c *Container) AttachedStdin() *Container
- func (c *Container) AttachedStdout() *Container
- func (c *Container) AutoRemove() *Container
- func (c *Container) BindMountWithPropagation(source, target string, propagation types.MountPropagation) *Container
- func (c *Container) BlkioDeviceReadBps(devicePath string, rate types.ByteSize) *Container
- func (c *Container) BlkioDeviceReadIOps(devicePath string, rate uint64) *Container
- func (c *Container) BlkioDeviceWriteBps(devicePath string, rate types.ByteSize) *Container
- func (c *Container) BlkioDeviceWriteIOps(devicePath string, rate uint64) *Container
- func (c *Container) BlkioWeight(weight uint16) *Container
- func (c *Container) CPUCount(count int64) *Container
- func (c *Container) CPUPercent(percent int64) *Container
- func (c *Container) CPUPeriod(period time.Duration) *Container
- func (c *Container) CPUQuota(quota time.Duration) *Container
- func (c *Container) CPURealtimePeriod(period time.Duration) *Container
- func (c *Container) CPURealtimeRuntime(runtime int64) *Container
- func (c *Container) CPUShares(shares int64) *Container
- func (c *Container) Cgroup(mode types.CgroupMode) *Container
- func (c *Container) CgroupParent(parent string) *Container
- func (c *Container) Command(cmd ...string) *Container
- func (c *Container) ConsoleSize(size types.ConsoleSize) *Container
- func (c *Container) ContainerIDFile(path string) *Container
- func (c *Container) CpusetCpus(cpus types.Cpuset) *Container
- func (c *Container) CpusetMems(mems types.Cpuset) *Container
- func (c *Container) DNSLookups(dns ...string) *Container
- func (c *Container) DNSOptions(dnsOption ...string) *Container
- func (c *Container) DNSSearches(search ...string) *Container
- func (c *Container) DeviceCgroupRules(rules ...string) *Container
- func (c *Container) DeviceRequest(req types.DeviceRequest) *Container
- func (c *Container) DisabledHealthCheck() *Container
- func (c *Container) DisabledNetwork() *Container
- func (c *Container) DomainName(domainname string) *Container
- func (c *Container) DroppedAllCapabilities() *Container
- func (c *Container) DroppedCapabilities(caps ...types.Capability) *Container
- func (c *Container) DroppedSensitiveCapabilities() *Container
- func (c *Container) Endpoint(name string, opts ...EndpointOpts) *Container
- func (c *Container) Entrypoint(entrypoint ...string) *Container
- func (c *Container) Env(key string, value string) *Container
- func (c *Container) EnvMap(env map[string]string) *Container
- func (c *Container) EscapedArgs() *Container
- func (c *Container) ExposedPort(protocol types.Protocol, port string) *Container
- func (c *Container) ExtraHost(hostname, ip string) *Container
- func (c *Container) HealthCheck(h Health) *Container
- func (c *Container) HostBindMountRecursiveRO(source, target string) *Container
- func (c *Container) HostName(hostname string) *Container
- func (c *Container) Image(image string) *Container
- func (c *Container) Imagef(stringFormat string, args ...any) *Container
- func (c *Container) Init() *Container
- func (c *Container) IpcMode(mode types.IpcMode) *Container
- func (c *Container) Isolation(mode types.Isolation) *Container
- func (c *Container) KernelMemory(memory types.ByteSize) *Container
- func (c *Container) Label(label, value string) *Container
- func (c *Container) LogDriver(driver string, options map[string]string) *Container
- func (c *Container) MaskedPaths(paths ...string) *Container
- func (c *Container) MemoryLimit(memory types.ByteSize) *Container
- func (c *Container) MemoryReservation(memory types.ByteSize) *Container
- func (c *Container) MemorySwap(memorySwap types.ByteSize) *Container
- func (c *Container) MemorySwappiness(swappiness int64) *Container
- func (c *Container) Mount(m Mount) *Container
- func (c *Container) NetworkMode(mode types.NetworkMode) *Container
- func (c *Container) NonRecursiveBindMount(source, target string, readonly bool) *Container
- func (c *Container) OS(OS string) *Container
- func (c *Container) OSFeatures(OSFeatures ...string) *Container
- func (c *Container) OSVersion(OSVersion string) *Container
- func (c *Container) OnBuild(args ...string) *Container
- func (c *Container) OomKillDisable() *Container
- func (c *Container) OomScoreAdj(score int) *Container
- func (c *Container) PidMode(mode types.PidMode) *Container
- func (c *Container) PidsLimit(limit int64) *Container
- func (c *Container) PortBinding(binding types.PortBinding) *Container
- func (c *Container) Privileged() *Container
- func (c *Container) PublishAllPorts() *Container
- func (c *Container) ROHostBindMount(source string, target string) *Container
- func (c *Container) RONamedVolumeMount(name, target string) *Container
- func (c *Container) RWHostBindMount(source string, target string) *Container
- func (c *Container) RWNamedVolumeMount(name, target string) *Container
- func (c *Container) RWNamedVolumeMountWithLabel(name, target, labelKey, labelValue string) *Container
- func (c *Container) RWNamedVolumeSubPath(name, target, subPath string) *Container
- func (c *Container) ReadOnlyRootfs() *Container
- func (c *Container) ReadonlyPaths(paths ...string) *Container
- func (c *Container) RestartAlways() *Container
- func (c *Container) RestartPolicy(mode types.RestartPolicy, maxRetryCount int) *Container
- func (c *Container) RestartPolicyAlways() *Container
- func (c *Container) RestartPolicyNever() *Container
- func (c *Container) RestartPolicyOnFailure(maxRetryCount int) *Container
- func (c *Container) RestartPolicyUnlessStopped() *Container
- func (c *Container) RestartUnlessStopped() *Container
- func (c *Container) Runtime(runtime string) *Container
- func (c *Container) SecurityOpts(opts ...string) *Container
- func (c *Container) Shell(shell ...string) *Container
- func (c *Container) ShmSize(size types.ByteSize) *Container
- func (c *Container) StdinOnce() *Container
- func (c *Container) StdinOpen() *Container
- func (c *Container) StopSignal(signal string) *Container
- func (c *Container) StopTimeout(timeout int) *Container
- func (c *Container) StorageOpt(key, value string) *Container
- func (c *Container) Sysctls(key, value string) *Container
- func (c *Container) Tmpfs(key, value string) *Container
- func (c *Container) TmpfsMount(target string, sizeBytes int, mode os.FileMode) *Container
- func (c *Container) TmpfsMountCustomOptions(target string, sizeBytes int, flags ...[]string) *Container
- func (c *Container) TmpfsMountExec(target string, sizeBytes int) *Container
- func (c *Container) TmpfsMountUIDGID(target string, sizeBytes int, uid, gid string) *Container
- func (c *Container) Tty() *Container
- func (c *Container) UTSMode(mode types.UTSMode) *Container
- func (c *Container) Ulimits(limit types.Ulimit) *Container
- func (c *Container) User(user string) *Container
- func (c *Container) UserNSMode(mode types.UserNSMode) *Container
- func (c *Container) Validate() error
- func (c *Container) Variant(variant string) *Container
- func (c *Container) Volume(volume string) *Container
- func (c *Container) VolumeBinds(binds ...string) *Container
- func (c *Container) VolumeDriver(driver string) *Container
- func (c *Container) VolumesFrom(name string, readOnly bool) *Container
- func (c *Container) WorkingDir(dir string) *Container
- type CopyOpts
- type Cp
- type Create
- type Deploy
- type Develop
- type DockerFile
- type Dockerfile
- func (d *Dockerfile) Add(src string, dest string, opts ...AddOpts) *Dockerfile
- func (d *Dockerfile) Arg(name string, defaultValue ...string) *Dockerfile
- func (d *Dockerfile) Check(value string) *Dockerfile
- func (d *Dockerfile) Command(executable string, args ...string) *Dockerfile
- func (d *Dockerfile) CommandShell(executable string, args ...string) *Dockerfile
- func (d *Dockerfile) Comment(comment string) *Dockerfile
- func (d *Dockerfile) Copy(src string, dest string, opts ...CopyOpts) *Dockerfile
- func (d *Dockerfile) Entrypoint(executable string, args ...string) *Dockerfile
- func (d *Dockerfile) EntrypointShell(executable string, args ...string) *Dockerfile
- func (d *Dockerfile) Env(key string, value string) *Dockerfile
- func (d *Dockerfile) Escape(char string) *Dockerfile
- func (d *Dockerfile) Export(path string, mode os.FileMode) error
- func (d *Dockerfile) Expose(port string) *Dockerfile
- func (d *Dockerfile) Format(args ...any) *Dockerfile
- func (d *Dockerfile) From(image string, tag ...string) *Dockerfile
- func (d *Dockerfile) FromAs(image, alias string) *Dockerfile
- func (d *Dockerfile) FromAsPlatform(platform, image, alias string) *Dockerfile
- func (d *Dockerfile) FromPlatform(platform, image string, tag ...string) *Dockerfile
- func (d *Dockerfile) HealthCheck(h Health) *Dockerfile
- func (d *Dockerfile) HealthCheckNone() *Dockerfile
- func (d *Dockerfile) Label(key string, value string) *Dockerfile
- func (d *Dockerfile) Onbuild(cmd string) *Dockerfile
- func (d *Dockerfile) Run(cmd string, opts ...RunOpts) *Dockerfile
- func (d *Dockerfile) RunArgs(args ...string) *Dockerfile
- func (d *Dockerfile) RunLayer(cmd string, opts ...RunOpts) *Dockerfile
- func (d *Dockerfile) Shell(executable string, args ...string) *Dockerfile
- func (d *Dockerfile) StopSignal(signal string) *Dockerfile
- func (d *Dockerfile) String() string
- func (d *Dockerfile) Syntax(frontend string) *Dockerfile
- func (d *Dockerfile) User(user string) *Dockerfile
- func (d *Dockerfile) Validate() error
- func (d *Dockerfile) Volumes(volumes ...string) *Dockerfile
- func (d *Dockerfile) Workdir(path string) *Dockerfile
- type Down
- type EndpointOpts
- type Events
- type EventsOpt
- type Exec
- type Generate
- type Global
- type Health
- func (h Health) CMD(args ...string) Health
- func (h Health) CMDShell(cmd string) Health
- func (h Health) Interval(seconds int) Health
- func (h Health) IntervalD(d string) Health
- func (h Health) None() Health
- func (h Health) Retries(n int) Health
- func (h Health) StartPeriod(seconds int) Health
- func (h Health) StartPeriodD(d string) Health
- func (h Health) Test(args ...string) Health
- func (h Health) Timeout(seconds int) Health
- func (h Health) TimeoutD(d string) Health
- type IPAMPool
- type ImageOptions
- type Images
- type Job
- type JobSchedule
- type Kill
- type Logs
- type Ls
- type Model
- type Mount
- type Pause
- type Port
- type Project
- func (p *Project) Export(file string, perm os.FileMode) error
- func (p *Project) ForEachService(fn func(name string, service *types.ServiceConfig) error) error
- func (p *Project) GetService(name string) (*types.ServiceConfig, error)
- func (p *Project) Marshal() ([]byte, error)
- func (p *Project) Print() error
- func (p *Project) ServiceLabel(key, value string) *Project
- func (p *Project) Unwrap() *types.Project
- func (p *Project) Validate() error
- func (p *Project) WithJob(name string, service *Container, job Job) *Project
- func (p *Project) WithModel(name string, model Model) *Project
- func (p *Project) WithNetwork(name string, spec ...ProjectNetwork) *Project
- func (p *Project) WithSecret(key string, spec ...ProjectSecret) *Project
- func (p *Project) WithService(service *Service) *Project
- func (p *Project) WithVolume(name string, spec ...ProjectVolume) *Project
- func (p *Project) WriteTo(w io.Writer) (int64, error)
- type ProjectLoad
- type ProjectNetwork
- type ProjectSecret
- type ProjectVolume
- type Ps
- type Publish
- type Pull
- type Push
- type Restart
- type Rm
- type Run
- type RunOpts
- type Scale
- type Service
- func (s *Service) Annotation(key, value string) *Service
- func (s *Service) Build(build Build) *Service
- func (s *Service) DependsOn(name string) *Service
- func (s *Service) DependsOnHealthy(name string) *Service
- func (s *Service) Deploy(deploy Deploy) *Service
- func (s *Service) Develop(watch Develop) *Service
- func (s *Service) Dockerfile(file DockerFile) *Service
- func (s *Service) EnvFile(path string) *Service
- func (s *Service) Model(name, endpointVar, modelVar string) *Service
- func (s *Service) NoAttach() *Service
- func (s *Service) PreStart(ctr *Container, perReplica bool) *Service
- func (s *Service) Profiles(profiles ...string) *Service
- func (s *Service) Secret(secret ServiceSecret) *Service
- type ServiceSecret
- type Start
- type Stats
- type Stop
- type TmpfsOptions
- type Top
- type Unpause
- type UnsupportedAttribute
- type Up
- type UpScale
- type Version
- type Viz
- type VolumeOptions
- type Volumes
- type Wait
- type Watch
- type WatchAction
Constants ¶
const ( SELinuxPrivate = "Z" )
SELinux relabel modes for a bind mount.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddOpts ¶
type AddOpts struct {
Chown string
Chmod string
Checksum string
KeepGitDir bool
Link bool
Exclude []string
}
AddOpts are optional flags on an ADD instruction.
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
Service string // required
}
Attach is the options for the compose attach command. Service is required.
type BindOptions ¶
type BindOptions struct {
Propagation types.MountPropagation
SELinux string // z or Z
NonRecursive bool
CreateHostPath *bool
ReadOnlyNonRecursive bool
ReadOnlyForceRecursive bool
}
BindOptions are options for a bind mount.
type BridgeConvert ¶
type BridgeConvert struct {
Output string // default out
Templates string
Transformations []string
Yes bool
Writer io.Writer
Profiles []string
}
BridgeConvert is the options for compose bridge convert.
type BridgeTransformationsCreate ¶
BridgeTransformationsCreate is the options for compose bridge transformations create.
type BridgeTransformationsList ¶
type BridgeTransformationsList struct {
Format string // table or json; default table
Quiet bool
Writer io.Writer
}
BridgeTransformationsList is the options for compose bridge transformations list.
type Build ¶
type Build struct {
// contains filtered or unexported fields
}
Build is a fluent Compose service build spec. Pass it to Service.Build. A later Build call is applied after earlier ones.
func NewBuildFrom ¶
NewBuildFrom starts a build spec from an existing BuildSpec value.
func (Build) AdditionalContext ¶
AdditionalContext sets one named additional build context.
func (Build) AdditionalContexts ¶
AdditionalContexts merges named additional build contexts.
func (Build) Apply ¶
func (b Build) Apply(cfg *types.ServiceConfig) error
Apply writes the build spec onto a Compose service.
func (Build) Dockerfile ¶
func (b Build) Dockerfile(file DockerFile) Build
Dockerfile sets the Dockerfile text from a DockerFile builder. A nil file is ignored. When validation fails, WithService reports the error and does not apply the spec.
func (Build) DockerfilePath ¶
DockerfilePath sets the Dockerfile path inside the context.
func (Build) Entitlement ¶
Entitlement appends build entitlements.
func (Build) NoCacheFilter ¶
NoCacheFilter appends cache filters that skip the cache.
func (Build) Privileged ¶
Privileged enables privileged mode for the build.
func (Build) Provenance ¶
Provenance sets the provenance attestation mode.
func (Build) Reader ¶
Reader returns the tar build context client.ImageBuild reads. Context is the directory to pack. A Dockerfile passed to Build.Dockerfile is written as Dockerfile over any Dockerfile already in that directory. When only Context or DockerfilePath is set, the file is read from disk (default "Dockerfile"). A .dockerignore in Context is honored. An empty Context packs only the Dockerfile.
func (Build) Secret ¶
func (b Build) Secret(secret BuildSecret) Build
Secret appends a build-time secret reference.
type BuildSecret ¶
BuildSecret is a build-time secret reference.
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
SSH []BuildSSH
AdditionalContexts map[string]string
ExtraHosts []string
Isolation string
ShmSize int64
Entitlements []string
Ulimits map[string]BuildUlimit
Secrets []BuildSecret
Provenance string
SBOM string
NoCacheFilter []string
// contains filtered or unexported fields
}
BuildSpec is Compose service build configuration.
func (BuildSpec) Apply ¶
func (b BuildSpec) Apply(cfg *composetypes.ServiceConfig) error
type BuildUlimit ¶
BuildUlimit is a soft/hard ulimit for a service build.
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
Service string // required
Repository string // optional REPOSITORY[:TAG]
}
Commit is the options for the compose commit command. Service is required.
type Compose ¶
type Compose struct {
// contains filtered or unexported fields
}
Compose runs a Project through the Docker Compose SDK.
func NewCompose ¶
NewCompose returns a Compose runner for the given project.
func (*Compose) BridgeConvert ¶
func (c *Compose) BridgeConvert(ctx context.Context, opt *BridgeConvert) error
BridgeConvert converts the project with a Compose bridge transformation.
func (*Compose) BridgeTransformationsCreate ¶
func (c *Compose) BridgeTransformationsCreate(ctx context.Context, opt *BridgeTransformationsCreate) error
BridgeTransformationsCreate copies a transformation image into Dest.
func (*Compose) BridgeTransformationsList ¶
func (c *Compose) BridgeTransformationsList(ctx context.Context, opt *BridgeTransformationsList) error
BridgeTransformationsList writes installed Compose bridge transformations.
func (*Compose) Build ¶
func (c *Compose) Build(ctx context.Context, opt *ComposeBuild) error
Build builds or rebuilds services.
func (*Compose) Config ¶
func (c *Compose) Config(ctx context.Context, opt *ComposeConfig) error
Config renders the project model.
func (*Compose) Cp ¶
Cp copies between a service container and the local filesystem. Source and Dest are required.
func (*Compose) Down ¶
Down stops and removes project resources. A nil opt uses defaults (writer is os.Stdout).
func (*Compose) Events ¶
Events streams compose events for the project. A nil opt watches every service and enables no profiles.
func (*Compose) Exec ¶
Exec runs a command in a running service container. Service and Command must be set on opt.
func (*Compose) Export ¶
func (c *Compose) Export(ctx context.Context, opt *ComposeExport) error
Export writes a service container filesystem as a tar archive. Service is required.
func (*Compose) Kill ¶
Kill stops service containers immediately. A nil opt uses defaults (writer is os.Stdout).
func (*Compose) LoadProject ¶
LoadProject loads a Compose project from files and returns it. Global compatibility, env files, working directory, all-resources, and dry-run apply.
func (*Compose) Logs ¶
Logs writes service logs to Writer. A nil opt uses defaults (writer is os.Stdout).
func (*Compose) Port ¶
Port prints the public address for a private port. Service and PrivatePort are required.
func (*Compose) Stats ¶
Stats writes container resource usage. The Compose SDK has no stats method, so this reads one-shot or streamed stats from the engine for project containers.
func (*Compose) Up ¶
Up creates and starts the project. A nil opt uses defaults (writer is os.Stdout).
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
}
ComposeBuild is the options for the compose build command
type ComposeConfig ¶
type ComposeConfig struct {
PrintEnvironment bool
Format string // yaml | json
PrintImages bool
PrintModels bool
PrintNetworks bool
NoConsistency bool
NoEnvResolution bool
NoInterpolate bool
NoNormalize bool
NoPathResolution bool
Output string
PrintProfiles bool
Quiet bool
PrintServices bool
PrintVariables bool
PrintVolumes bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
ComposeConfig is the options for the compose config command. Named ComposeConfig because Config is too generic (MergedConfig, container.Config).
type ComposeExport ¶
type ComposeExport struct {
Index *int
Output string
Writer io.Writer
Profiles []string
Service string // required
}
ComposeExport is the options for the compose export command. Named ComposeExport to avoid confusion with Project.Export. Service is required.
type Container ¶
type Container struct {
Name string // the name of the container
Config *types.MergedConfig // merged docker sdk configuration for container creation
Errors []error // errors encountered during configuration
// contains filtered or unexported fields
}
func NewContainer ¶
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 ...types.Capability) *Container
AddedCapabilities adds capabilities to the host configuration for the container. parameters:
- caps: the capabilities to add
func (*Container) AddedDevice ¶
AddedDevice maps a host device into the container.
func (*Container) AddedGroups ¶
AddedGroups appends supplementary groups to the host configuration for the container. parameters:
- group: the group to add
func (*Container) Architecture ¶
Architecture sets the platform CPU architecture, for example amd64 or ppc64le. Parameter:
- architecture: the architecture to be used for the platform
Architecture field specifies the CPU architecture, for example `amd64` or `ppc64le`.
func (*Container) AttachedStderr ¶
func (*Container) AttachedStdin ¶
func (*Container) AttachedStdout ¶
func (*Container) AutoRemove ¶
AutoRemove sets the container to be automatically removed when it exits.
func (*Container) BindMountWithPropagation ¶
func (c *Container) BindMountWithPropagation(source, target string, propagation types.MountPropagation) *Container
func (*Container) BlkioDeviceReadBps ¶
BlkioDeviceReadBps limits the read rate for one device.
func (*Container) BlkioDeviceReadIOps ¶
BlkioDeviceReadIOps appends a block IO read operations per second (IOPS) limit for a specific device to the container's host configuration.
Parameters:
- devicePath: the device path (e.g., "/dev/sda")
- rate: the maximum read IOPS limit
func (*Container) BlkioDeviceWriteBps ¶
BlkioDeviceWriteBps limits the write rate for one device.
func (*Container) BlkioDeviceWriteIOps ¶
BlkioDeviceWriteIOps appends a block IO write operations per second (IOPS) limit for a specific device to the container's host configuration.
Parameters:
- devicePath: the device path (e.g., "/dev/sda")
- rate: the maximum write IOPS limit
func (*Container) BlkioWeight ¶
BlkioWeight sets the block IO weight (relative weight) for the container. Weight is a value between 10 and 1000. parameters:
- weight: the block IO weight
func (*Container) CPUCount ¶
CPUCount sets the number of CPUs allocated to the container in the host configuration.
Parameters:
- count: the number of CPUs to allocate to the container.
Returns an error if count is less than 1.
func (*Container) CPUPercent ¶
CPUPercent sets the CPU percentage limit for the container.
This option specifies the maximum amount of CPU the container can use as a percentage (e.g., 50 means the container can use up to 50% of one CPU core).
Parameters:
- percent: the desired CPU limit as a percentage (0–100, or more for multi-core allocation).
Returns an error if the percent is negative.
func (*Container) CPUPeriod ¶
CPUPeriod sets the CFS period. Zero leaves it unset. A positive period must be from 1ms through 1s.
func (*Container) CPURealtimePeriod ¶
CPURealtimePeriod sets the real-time scheduling period. Zero leaves it unset. A positive period must be from 1ms through 1s.
func (*Container) CPURealtimeRuntime ¶
CPURealtimeRuntime sets the CPU real-time runtime in microseconds. A value of -1 disables the limit (default). parameters:
- runtime: the CPU real-time runtime in microseconds
func (*Container) CPUShares ¶
CPUShares sets the CPU shares (relative weight) for the container.
CPU shares define the relative CPU time available to the container compared to others. For example, 1024 is the default (normal priority), 512 is half the CPU weight, 2048 is double.
Parameters:
- shares: the number of CPU shares (must be a positive integer).
Returns an error if the value is less than or equal to zero.
func (*Container) Cgroup ¶
func (c *Container) Cgroup(mode types.CgroupMode) *Container
Cgroup sets the container cgroup namespace.
func (*Container) CgroupParent ¶
func (*Container) Command ¶
Command appends the command to be run in the container Parameters:
- cmd: command and its arguments
func (*Container) ConsoleSize ¶
func (c *Container) ConsoleSize(size types.ConsoleSize) *Container
ConsoleSize sets the container console height and width.
func (*Container) ContainerIDFile ¶
ContainerIDFile sets the path to a file where the container ID will be written after creation.
After `client.ContainerCreate`, Docker will write the container's ID to this file. This is useful for external tooling or scripts that need to reference the container after it starts.
Parameters:
- path: absolute or relative path to the container ID file.
Returns an error if the path is empty or only whitespace.
func (*Container) CpusetCpus ¶
CpusetCpus sets the CPUs in which execution is allowed.
func (*Container) CpusetMems ¶
CpusetMems sets the memory nodes in which execution is allowed. Only effective on NUMA systems.
func (*Container) DNSLookups ¶
DNSLookups appends a DNS server to the host configuration for the container. parameters:
- dns: the DNS server to add
func (*Container) DNSOptions ¶
DNSOptions appends a DNS option to the host configuration for the container. parameters:
- dnsOption: the DNS option to add
func (*Container) DNSSearches ¶
DNSSearches appends a DNS search domain to the host configuration for the container. parameters:
- search: the DNS search domain to add
func (*Container) DeviceCgroupRules ¶
DeviceCgroupRules appends device cgroup rules to the container's host configuration. Device cgroup rules control access to devices inside the container.
Parameters:
- rules: one or more device cgroup rule strings (e.g., "c 1:3 rwm").
Note: Rules must follow the device cgroup format accepted by the Linux kernel.
func (*Container) DeviceRequest ¶
func (c *Container) DeviceRequest(req types.DeviceRequest) *Container
DeviceRequest appends a device request, such as a GPU, to the container.
func (*Container) DisabledHealthCheck ¶
DisabledHealthCheck disables the healthcheck.
func (*Container) DisabledNetwork ¶
func (*Container) DomainName ¶
DomainName sets the domain name of the container
func (*Container) DroppedAllCapabilities ¶
DroppedAllCapabilities drops all capabilities
func (*Container) DroppedCapabilities ¶
func (c *Container) DroppedCapabilities(caps ...types.Capability) *Container
DroppedCapabilities drops capabilities from the host configuration for the container. parameters:
- caps: the capabilities to drop
func (*Container) DroppedSensitiveCapabilities ¶
DroppedSensitiveCapabilities drops a common set of sensitive capabilities
SYS_ADMIN, SYS_MODULE, SYS_PTRACE, SYS_TIME, SYSLOG, MAC_ADMIN, MAC_OVERRIDE, CHECKPOINT_RESTORE
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 ¶
Entrypoint sets the entrypoint to be run within the container
func (*Container) Env ¶
Env appends an environment variable and its value to the container configuration Parameters:
- key: environment variable name
- value: environment variable value
func (*Container) EnvMap ¶
EnvMap appends a map of environment variables to the container configuration Parameters:
- env: map of environment variables
func (*Container) EscapedArgs ¶
func (*Container) ExposedPort ¶
ExposedPort appends a port to be exposed from the container Parameter:
- port: port number or port range to be exposed in the container (e.g., "80-1000" or "80")
- protocol: protocol to be exposed from the container
func (*Container) HealthCheck ¶
HealthCheck sets the container healthcheck from a Health value.
func (*Container) HostBindMountRecursiveRO ¶
func (*Container) Init ¶
Init sets the init flag for the container parameters:
- init: the init flag to use
Note: use to run a custom init inside the container, if null, use the daemon's configured settings
func (*Container) KernelMemory ¶
KernelMemory sets the kernel memory limit.
func (*Container) Label ¶
Label appends a label to the container Parameters:
- label: label key
- value: label value
func (*Container) MaskedPaths ¶
MaskedPaths appends a list of paths to be masked inside the container.
Masked paths are mounted as read-only and inaccessible from within the container, overriding the default masked paths (e.g., "/proc/kcore", "/proc/latency_stats").
Parameters:
- paths: one or more absolute paths to mask
Returns an error if any path is empty or not absolute.
func (*Container) MemoryLimit ¶
MemoryLimit sets the container memory limit.
func (*Container) MemoryReservation ¶
MemoryReservation sets the memory soft limit.
func (*Container) MemorySwap ¶
MemorySwap sets the total memory limit, including swap.
func (*Container) MemorySwappiness ¶
MemorySwappiness tunes container memory swappiness (0 to 100). - A value of 0 turns off anonymous page swapping. - A value of 100 sets the host's swappiness value. - Values between 0 and 100 modify the swappiness level accordingly. parameters:
- swappiness: the swappiness level
func (*Container) NetworkMode ¶
func (c *Container) NetworkMode(mode types.NetworkMode) *Container
NetworkMode sets the container network namespace.
func (*Container) NonRecursiveBindMount ¶
func (*Container) OS ¶
OS sets the OS for the platform Parameter:
- OS: the OS to be used for the platform
OS specifies the operating system, for example `linux` or `windows`.
func (*Container) OSFeatures ¶
OSFeatures sets the OS features for the platform Parameter:
- OSFeatures: the OS features to be used for the platform
OSFeatures is an optional field specifying an array of strings, each listing a required OS feature (for example on Windows `win32k`).
func (*Container) OSVersion ¶
OSVersion sets the OS version for the platform Parameter:
- OSVersion: the OS version to be used for the platform
OSVersion is an optional field specifying the operating system version, for example on Windows `10.0.14393.1066`.
func (*Container) OnBuild ¶
OnBuild appends ONBUILD metadata that will trigger when the image is used as a base image
func (*Container) OomKillDisable ¶
OomKillDisable sets the OOM kill disable flag for the container in the host configuration. parameters:
- oomKillDisable: the OOM kill disable flag to use
func (*Container) OomScoreAdj ¶
OomScoreAdj sets the Out-Of-Memory (OOM) score adjustment for the container.
The OOM score adjustment ranges from -1000 to 1000 and tells the kernel how likely it is to kill the container’s process when the system is under memory pressure. - A value closer to -1000 means the process is protected from OOM killing. - A value closer to 1000 makes the process more likely to be killed.
Parameters:
- score: an integer between -1000 and 1000 (inclusive)
Returns an error if the score is outside the valid range.
func (*Container) PidsLimit ¶
PidsLimit sets the container's PIDs limit. parameters:
- limit: the PIDs limit
func (*Container) PortBinding ¶
func (c *Container) PortBinding(binding types.PortBinding) *Container
PortBinding publishes one container port on the host. An empty Protocol defaults to TCP. An empty HostIP defaults to 0.0.0.0.
func (*Container) Privileged ¶
func (*Container) PublishAllPorts ¶
func (*Container) ROHostBindMount ¶
func (*Container) RONamedVolumeMount ¶
func (*Container) RWHostBindMount ¶
func (*Container) RWNamedVolumeMount ¶
func (*Container) RWNamedVolumeMountWithLabel ¶
func (*Container) RWNamedVolumeSubPath ¶
func (*Container) ReadOnlyRootfs ¶
func (*Container) ReadonlyPaths ¶
ReadonlyPaths appends a list of paths to be marked as read-only inside the container.
These paths are mounted as read-only from the host and are inaccessible for writing by any process in the container.
Parameters:
- paths: one or more absolute paths to mark as read-only
Returns an error if any path is empty or not absolute.
func (*Container) RestartAlways ¶
RestartAlways sets a restart policy that ensures the container is always restarted upon exit. This policy restarts the container indefinitely, ignoring any retry limits.
func (*Container) RestartPolicy ¶
func (c *Container) RestartPolicy(mode types.RestartPolicy, maxRetryCount int) *Container
RestartPolicy sets the container restart policy. maxRetryCount applies to RestartPolicyOnFailure.
func (*Container) RestartPolicyAlways ¶
RestartPolicyAlways restarts the container whenever it exits.
func (*Container) RestartPolicyNever ¶
RestartPolicyNever does not restart the container.
func (*Container) RestartPolicyOnFailure ¶
RestartPolicyOnFailure restarts the container when it exits with an error.
func (*Container) RestartPolicyUnlessStopped ¶
RestartPolicyUnlessStopped restarts the container unless it was stopped.
func (*Container) RestartUnlessStopped ¶
RestartUnlessStopped is an alias for RestartPolicyUnlessStopped.
func (*Container) SecurityOpts ¶
SecurityOpts appends security options to the container's host configuration.
These options customize security labels or settings used by Mandatory Access Control (MAC) systems like SELinux, AppArmor, or Seccomp. They allow fine-tuning container security contexts, such as specifying custom SELinux labels or disabling certain security profiles.
Docker itself does minimal validation on these strings, so this function simply appends them. Users should provide valid options according to their security system's documentation.
parameters:
- opts: a variadic list of security options to append (e.g., SELinux labels or profile overrides)
func (*Container) StopSignal ¶
StopSignal sets the signal that will be used to stop the container
func (*Container) StopTimeout ¶
StopTimeout sets the timeout (in seconds) to stop the container
note: is also stop_grace_period in compose
func (*Container) StorageOpt ¶
StorageOpt appends a storage driver option for the container's host configuration. Storage options are key-value pairs passed to the container storage driver to configure specific behaviors like size limits, encryption, or performance settings.
Since storage options are driver-specific and Docker itself does minimal validation, this function trims whitespace and requires a non-empty key to avoid invalid or meaningless options that might cause runtime errors or unexpected behavior.
parameters:
- key: the storage option key (must be non-empty after trimming whitespace)
- value: the value for the storage option
func (*Container) Sysctls ¶
Sysctls adds or updates a sysctl key-value pair in the container's host configuration. Sysctls allow tuning of kernel parameters inside the container.
Parameters:
- key: the sysctl parameter name (e.g., "net.ipv4.ip_forward")
- value: the sysctl parameter value (e.g., "1")
Note: The effectiveness of sysctls depends on the container runtime and host kernel support.
func (*Container) Tmpfs ¶
Tmpfs appends to a map of tmpfs (mounts) used for the container parameters:
- key: the key of the tmpfs option
- value: the value of the tmpfs option
func (*Container) TmpfsMount ¶
func (*Container) TmpfsMountCustomOptions ¶
func (*Container) TmpfsMountExec ¶
func (*Container) TmpfsMountUIDGID ¶
func (*Container) UserNSMode ¶
func (c *Container) UserNSMode(mode types.UserNSMode) *Container
UserNSMode sets the container user namespace.
func (*Container) Validate ¶
Validate validates the container config. It will return an error if the container has errors.
func (*Container) Variant ¶
Variant sets the variant for the platform Parameter:
- variant: the variant to be used for the platform
Variant is an optional field specifying a variant of the CPU, for example `v7` to specify ARMv7 when architecture is `arm`.
func (*Container) Volume ¶
Volume appends a short hand volume mount point to the container Parameter:
- volume: path where the volume should be mounted
note: Compose maps this to an anonymous volume at the container path. Named volumes use Mount or RWNamedVolumeMount.
func (*Container) VolumeBinds ¶
VolumeBinds parses short mount strings into Mount values. Format is source:target[:mode]. Mode is optional and defaults to read-write. A source with no path separator is a named volume. Absolute, relative, and Windows paths are binds. Mode tokens: ro, rw, readonly, z, Z, consistent, cached, delegated, rshared, shared, rslave, slave, rprivate, private.
func (*Container) VolumeDriver ¶
VolumeDriver sets the volume driver for the container in the host configuration.
The volume driver specifies the plugin or mechanism used to manage volumes mounted into the container. This option is typically only used with the Docker API directly, not with Docker Compose.
Parameters:
- driver: the name of the volume driver to use.
Returns an error if the driver name is empty or contains only whitespace.
func (*Container) VolumesFrom ¶
VolumesFrom inherits volumes from another container. readOnly maps to the :ro suffix. A writable inherit stores the container name alone.
func (*Container) WorkingDir ¶
WorkingDir sets the working directory for commands to run in
type CopyOpts ¶
type CopyOpts struct {
From string
Chown string
Chmod string
Link bool
Exclude []string
Parents bool
}
CopyOpts are optional flags on a COPY instruction.
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
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 "-").
type Create ¶
type Create struct {
Build bool
ForceRecreate bool
NoBuild bool
NoRecreate bool
Pull string
QuietPull bool
RemoveOrphans bool
IgnoreOrphans bool
Scale []UpScale
Yes bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Create is the options for the compose create command.
type Deploy ¶
type Deploy struct {
Mode string
Replicas *int
Labels map[string]string
Limits *types.Resources
Reservations *types.Resources
}
Deploy is Compose deploy configuration.
func (Deploy) Apply ¶
func (d Deploy) Apply(cfg *composetypes.ServiceConfig) error
type Develop ¶
type Develop struct {
Action WatchAction
Path string
Target string
Ignore []string
}
Develop is one Compose develop watch rule.
type DockerFile ¶
DockerFile is the contract consumed by Build.Dockerfile. *Dockerfile from NewDockerFile, ParseDockerfile, and ReadDockerfile implements it.
type Dockerfile ¶
type Dockerfile struct {
// contains filtered or unexported fields
}
Dockerfile is a fluent Dockerfile builder.
Not safe for concurrent use.
func NewDockerFile ¶
func NewDockerFile() *Dockerfile
NewDockerFile creates a fluent Dockerfile builder.
func ParseDockerfile ¶
func ParseDockerfile(content string) *Dockerfile
ParseDockerfile wraps existing Dockerfile text. An empty string records a validation error.
func ReadDockerfile ¶
func ReadDockerfile(path string) *Dockerfile
ReadDockerfile reads a Dockerfile from path. Read errors are returned by Validate.
func (*Dockerfile) Add ¶
func (d *Dockerfile) Add(src string, dest string, opts ...AddOpts) *Dockerfile
Add sets an ADD instruction. At most one AddOpts value is accepted.
func (*Dockerfile) Arg ¶
func (d *Dockerfile) Arg(name string, defaultValue ...string) *Dockerfile
Arg sets an ARG instruction, with an optional default value.
func (*Dockerfile) Check ¶
func (d *Dockerfile) Check(value string) *Dockerfile
Check sets the # check= parser directive.
func (*Dockerfile) Command ¶
func (d *Dockerfile) Command(executable string, args ...string) *Dockerfile
Command sets CMD in JSON exec form. A second CMD records an error and is not written.
func (*Dockerfile) CommandShell ¶
func (d *Dockerfile) CommandShell(executable string, args ...string) *Dockerfile
CommandShell sets CMD in shell form. A second CMD records an error and is not written.
func (*Dockerfile) Comment ¶
func (d *Dockerfile) Comment(comment string) *Dockerfile
Comment writes a dockerfile comment.
func (*Dockerfile) Copy ¶
func (d *Dockerfile) Copy(src string, dest string, opts ...CopyOpts) *Dockerfile
Copy sets a COPY instruction. At most one CopyOpts value is accepted.
func (*Dockerfile) Entrypoint ¶
func (d *Dockerfile) Entrypoint(executable string, args ...string) *Dockerfile
Entrypoint sets the JSON exec form of ENTRYPOINT.
func (*Dockerfile) EntrypointShell ¶
func (d *Dockerfile) EntrypointShell(executable string, args ...string) *Dockerfile
EntrypointShell sets the shell form of ENTRYPOINT.
func (*Dockerfile) Env ¶
func (d *Dockerfile) Env(key string, value string) *Dockerfile
Env sets an ENV instruction.
func (*Dockerfile) Escape ¶
func (d *Dockerfile) Escape(char string) *Dockerfile
Escape sets the # escape= parser directive. char must be \ or `.
func (*Dockerfile) Export ¶
func (d *Dockerfile) Export(path string, mode os.FileMode) error
Export writes the dockerfile to path after validation.
func (*Dockerfile) Expose ¶
func (d *Dockerfile) Expose(port string) *Dockerfile
Expose sets an EXPOSE instruction.
func (*Dockerfile) Format ¶
func (d *Dockerfile) Format(args ...any) *Dockerfile
Format formats the dockerfile with the given arguments and replaces its contents.
func (*Dockerfile) From ¶
func (d *Dockerfile) From(image string, tag ...string) *Dockerfile
From sets the FROM instruction. Pass the tag in image ("alpine:latest") or as the second argument.
func (*Dockerfile) FromAs ¶
func (d *Dockerfile) FromAs(image, alias string) *Dockerfile
FromAs sets FROM image AS alias. image may include a tag.
func (*Dockerfile) FromAsPlatform ¶
func (d *Dockerfile) FromAsPlatform(platform, image, alias string) *Dockerfile
FromAsPlatform sets FROM --platform=platform image AS alias.
func (*Dockerfile) FromPlatform ¶
func (d *Dockerfile) FromPlatform(platform, image string, tag ...string) *Dockerfile
FromPlatform sets FROM --platform=platform.
func (*Dockerfile) HealthCheck ¶
func (d *Dockerfile) HealthCheck(h Health) *Dockerfile
Healthcheck sets a HEALTHCHECK instruction from a container Health value. Zero interval, timeout, start period, and retries are omitted.
func (*Dockerfile) HealthCheckNone ¶
func (d *Dockerfile) HealthCheckNone() *Dockerfile
HealthCheckNone sets HEALTHCHECK NONE.
func (*Dockerfile) Label ¶
func (d *Dockerfile) Label(key string, value string) *Dockerfile
Label sets a LABEL instruction.
func (*Dockerfile) Onbuild ¶
func (d *Dockerfile) Onbuild(cmd string) *Dockerfile
Onbuild sets an ONBUILD instruction.
func (*Dockerfile) Run ¶
func (d *Dockerfile) Run(cmd string, opts ...RunOpts) *Dockerfile
Run sets a RUN instruction. Consecutive Run calls with no flags are joined with "&& \" into one layer. A call that sets RunOpts starts a new RUN.
func (*Dockerfile) RunArgs ¶
func (d *Dockerfile) RunArgs(args ...string) *Dockerfile
RunArgs continues the previous RUN with newline continuation and no "&&".
func (*Dockerfile) RunLayer ¶
func (d *Dockerfile) RunLayer(cmd string, opts ...RunOpts) *Dockerfile
RunLayer starts a new RUN instruction. Unlike Run, it does not fold into the previous RUN.
func (*Dockerfile) Shell ¶
func (d *Dockerfile) Shell(executable string, args ...string) *Dockerfile
Shell sets the SHELL instruction (JSON exec form).
func (*Dockerfile) StopSignal ¶
func (d *Dockerfile) StopSignal(signal string) *Dockerfile
StopSignal sets a STOPSIGNAL instruction.
func (*Dockerfile) String ¶
func (d *Dockerfile) String() string
String returns the dockerfile text.
func (*Dockerfile) Syntax ¶
func (d *Dockerfile) Syntax(frontend string) *Dockerfile
Syntax sets the # syntax= parser directive.
func (*Dockerfile) User ¶
func (d *Dockerfile) User(user string) *Dockerfile
User sets a USER instruction.
func (*Dockerfile) Validate ¶
func (d *Dockerfile) Validate() error
Validate returns any errors recorded while building the dockerfile.
func (*Dockerfile) Volumes ¶
func (d *Dockerfile) Volumes(volumes ...string) *Dockerfile
Volumes sets a VOLUME instruction.
func (*Dockerfile) Workdir ¶
func (d *Dockerfile) Workdir(path string) *Dockerfile
Workdir sets a WORKDIR instruction.
type Down ¶
type Down struct {
RemoveOrphans bool
Timeout *int
RemoveImage *string
RemoveVolumes bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Down is the options for the compose down command
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 EventsOpt ¶
EventsOpt is the options for the compose events command. A nil EventsOpt watches every service and enables no profiles.
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.
type Generate ¶
type Generate struct {
Name string
ProjectDir string
Format string // yaml or json; default yaml
Containers []string
Writer io.Writer
}
Generate is the options for compose alpha generate.
type Global ¶
type Global struct {
Progress string
ANSI string
Parallel *int
AllResources bool
EnvFile []string
Compatibility bool
ProjectDirectory string
DryRun bool
}
Global holds Compose-wide settings applied to every command on this runner.
type Health ¶
type Health struct {
// contains filtered or unexported fields
}
Health is a fluent container healthcheck. Pass it to Container.HealthCheck and Dockerfile.Healthcheck. Timeout/Interval/StartPeriod are seconds unless the matching *D method is used ("2s", "1m").
func (Health) Retries ¶
Retries sets the number of consecutive failures needed to mark the container unhealthy.
func (Health) StartPeriod ¶
StartPeriod sets the start-period in seconds.
func (Health) StartPeriodD ¶
StartPeriodD sets the start-period from a duration string ("0s").
func (Health) Test ¶
Test sets the healthcheck command, including the CMD / CMD-SHELL / NONE prefix.
type IPAMPool ¶
type IPAMPool struct {
Subnet string
Gateway string
IPRange string
AuxiliaryAddresses map[string]string
}
IPAMPool is a project network IPAM pool.
type ImageOptions ¶
type ImageOptions struct {
Subpath string
}
ImageOptions are options for an image mount.
type Images ¶
type Images struct {
Format string // table | json
Quiet bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Images is the options for the compose images command.
type Job ¶
type Job struct {
Profiles []string
Manual *bool
Schedule []JobSchedule
}
Job is the trigger and profile configuration for a Compose job.
type JobSchedule ¶
JobSchedule is one cron trigger for a Compose job.
type Kill ¶
type Kill struct {
Signal *string
RemoveOrphans bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Kill is the options for the compose kill command
type Logs ¶
type Logs struct {
Tail *int
Follow bool
Index *int
NoColor bool
NoLogPrefix bool
Since string
Timestamps bool
Until string
Writer io.Writer
Profiles []string
ServiceNames []string
}
Logs is the options for the compose logs command
type Ls ¶
type Ls struct {
All bool
Filter []string
Format string
Quiet bool
Writer io.Writer
Profiles []string
}
Ls is the options for the compose ls command (lists Compose projects on the engine).
type Mount ¶
type Mount struct {
Source string
Target string
Type types.MountType
ReadOnly bool
Consistency types.MountConsistency
Bind *BindOptions
Volume *VolumeOptions
Tmpfs *TmpfsOptions
Image *ImageOptions
}
Mount describes one mount. Empty Type is bind, unless Volume, Tmpfs, or Image is set.
type Port ¶
type Port struct {
Index *int
Protocol string // tcp | udp
Writer io.Writer
Profiles []string
Service string // required
PrivatePort int // required
}
Port is the options for the compose port command. Service and PrivatePort are required.
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 ¶
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) ForEachService ¶
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) ServiceLabel ¶
ServiceLabel sets a label on every service that does not already have key. Empty key or value is ignored. Labels added after WithService still reach Compose Up; mutating the original *Container does not.
func (*Project) Validate ¶
Validate validates the project returns an error if the project has errors
func (*Project) WithJob ¶
WithJob defines a Compose job from a container spec. Deploy and develop extras are service-only.
func (*Project) WithNetwork ¶
func (p *Project) WithNetwork(name string, spec ...ProjectNetwork) *Project
WithNetwork defines a project network. spec is optional and at most one value.
func (*Project) WithSecret ¶
func (p *Project) WithSecret(key string, spec ...ProjectSecret) *Project
WithSecret defines a new secret in the project
func (*Project) WithService ¶
WithService adds a service to the project.
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 ProjectLoad ¶
type ProjectLoad struct {
Name string
Files []string
WorkingDir string
EnvFiles []string
Profiles []string
Services []string
Offline bool
AllResources bool
Compatibility bool
InsecureRegistries []string
OnUnsupported func([]UnsupportedAttribute)
Writer io.Writer
}
ProjectLoad is the options for loading a Compose project from files.
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
}
Ps is the options for the compose ps command
type Publish ¶
type Publish struct {
App bool
OCIVersion string
ResolveImageDigests bool
InsecureRegistry bool
WithEnv bool
Yes bool
Writer io.Writer
Profiles []string
Repository string // required REPOSITORY[:TAG]
}
Publish is the options for the compose publish command. Repository is required.
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
}
Pull is the options for the compose pull command
type Push ¶
type Push struct {
IgnorePushFailures bool
IncludeDeps bool
Quiet bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Push is the options for the compose push command.
type Restart ¶
type Restart struct {
NoDeps bool
Timeout *int
Writer io.Writer
Profiles []string
ServiceNames []string
}
Restart is the options for the compose restart command
type Rm ¶
type Rm struct {
Force bool
Stop bool
Volumes bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Rm is the options for the compose rm command.
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
Pull string
Quiet bool
QuietBuild bool
QuietPull bool
RemoveOrphans bool
IgnoreOrphans bool
Rm bool
UseAliases bool
User string
Workdir string
Writer io.Writer
Stdin io.Reader
Profiles []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).
type RunOpts ¶
RunOpts are BuildKit flags on a RUN instruction. Setting any flag starts a new RUN. Later Run calls with empty options still fold into that instruction.
type Scale ¶
Scale is the options for the compose scale command. Replicas is required (at least one SERVICE=NUM).
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a Compose service: a container plus the settings that exist only on a service.
func NewService ¶
NewService returns a service named name using the container as its runtime config.
func (*Service) Annotation ¶
Annotation sets a service annotation.
func (*Service) Build ¶
Build sets the service build spec. A later Build call is applied after earlier ones.
func (*Service) DependsOn ¶
DependsOn marks the service as depending on another (condition: started).
func (*Service) DependsOnHealthy ¶
DependsOnHealthy marks the service as depending on another becoming healthy.
func (*Service) Dockerfile ¶
func (s *Service) Dockerfile(file DockerFile) *Service
Dockerfile sets the service's inline Dockerfile directly without needing NewBuild.
func (*Service) PreStart ¶
PreStart adds a run-to-completion hook that runs before the service starts.
func (*Service) Secret ¶
func (s *Service) Secret(secret ServiceSecret) *Service
Secret adds a service-level secret reference.
type ServiceSecret ¶
ServiceSecret is a service-level secret reference.
func (ServiceSecret) Apply ¶
func (s ServiceSecret) Apply(cfg *composetypes.ServiceConfig) error
type Start ¶
type Start struct {
Wait bool
WaitTimeout *int
Writer io.Writer
Profiles []string
ServiceNames []string
}
Start is the options for the compose start command
type Stats ¶
type Stats struct {
All bool
Format string
NoStream bool
NoTrunc bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Stats is the options for the compose stats command.
type TmpfsOptions ¶
TmpfsOptions are options for a tmpfs mount.
type UnsupportedAttribute ¶
UnsupportedAttribute is a compose-file attribute the schema accepts and this runtime does not apply outside Swarm.
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
IgnoreOrphans bool
RenewAnonVolumes bool
Scale []UpScale
Timeout *int
Timestamps bool
Wait bool
WaitTimeout *int
Watch bool
Yes bool
Profiles []string
Writer io.Writer
ServiceNames []string
}
Up is the options for the compose up command
type Version ¶
type Version struct {
Format string // pretty | json
Short bool
Writer io.Writer
Profiles []string
}
Version is the options for the compose version command.
type Viz ¶
type Viz struct {
Networks bool
Ports bool
Image bool
IndentationSize *int // default 1
Spaces bool
Writer io.Writer
Profiles []string
}
Viz is the options for compose alpha viz.
type VolumeOptions ¶
type VolumeOptions struct {
NoCopy bool
Labels map[string]string
Subpath string
Driver string
DriverOptions map[string]string
}
VolumeOptions are options for a named volume mount.
type Volumes ¶
type Volumes struct {
Format string
Quiet bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Volumes is the options for the compose volumes command.
type Wait ¶
type Wait struct {
DownProject bool
Writer io.Writer
Profiles []string
ServiceNames []string // required
}
Wait is the options for the compose wait command. ServiceNames is required.
type Watch ¶
type Watch struct {
NoUp bool
NoPrune bool // --prune=false; Compose defaults to true
Quiet bool
Writer io.Writer
Profiles []string
ServiceNames []string
}
Watch is the options for the compose watch command.
type WatchAction ¶
type WatchAction string
WatchAction is a Compose develop watch action.
const ( WatchActionSync WatchAction = "sync" WatchActionRebuild WatchAction = "rebuild" WatchActionSyncRestart WatchAction = "sync+restart" )