Documentation
¶
Index ¶
- Variables
- func LoadDockerConfig() (*configfile.ConfigFile, error)
- func PrepareForGroupCancellation(cmd *exec.Cmd)
- type Client
- type ContainerRuntime
- type DockerBuilder
- type DockerHelper
- func (r *DockerHelper) ClientVersion(ctx context.Context) string
- func (r *DockerHelper) DeleteVolume(ctx context.Context, volume string) error
- func (r *DockerHelper) EnsureElevated() error
- func (r *DockerHelper) FindContainer(ctx context.Context, labels []string) ([]string, error)
- func (r *DockerHelper) FindContainerByID(ctx context.Context, containerIds []string) (*config.ContainerDetails, error)
- func (r *DockerHelper) FindContainerJSON(ctx context.Context, labels []string) ([]string, error)
- func (r *DockerHelper) FindDevContainer(ctx context.Context, labels []string) (*config.ContainerDetails, error)
- func (r *DockerHelper) GPUSupportEnabled() (bool, error)
- func (r *DockerHelper) GetContainerLogs(ctx context.Context, id string, stdout io.Writer, stderr io.Writer) error
- func (r *DockerHelper) GetImageTag(ctx context.Context, imageID string) (string, error)
- func (r *DockerHelper) GetRuntime() ContainerRuntime
- func (r *DockerHelper) Inspect(ctx context.Context, ids []string, inspectType string, obj any) error
- func (r *DockerHelper) InspectContainers(ctx context.Context, ids []string) ([]config.ContainerDetails, error)
- func (r *DockerHelper) InspectImage(ctx context.Context, imageName string, tryRemote bool) (*config.ImageDetails, error)
- func (r *DockerHelper) IsNerdctl() bool
- func (r *DockerHelper) IsPodman() bool
- func (r *DockerHelper) LingerWarning(ctx context.Context) string
- func (r *DockerHelper) Ping(ctx context.Context) error
- func (r *DockerHelper) PodmanMachineExists(ctx context.Context) (bool, error)
- func (r *DockerHelper) Pull(ctx context.Context, opts PullOptions) error
- func (r *DockerHelper) Remove(ctx context.Context, id string) error
- func (r *DockerHelper) Run(ctx context.Context, args []string, streams Streams) error
- func (r *DockerHelper) RunWithDir(ctx context.Context, dir string, args []string, streams Streams) error
- func (r *DockerHelper) RunWithEnv(ctx context.Context, extraEnv []string, args []string, streams Streams) error
- func (r *DockerHelper) StartContainer(ctx context.Context, containerId string) error
- func (r *DockerHelper) StartPodmanMachine(ctx context.Context) error
- func (r *DockerHelper) StartRootlessPodmanSocket(ctx context.Context) error
- func (r *DockerHelper) Stop(ctx context.Context, id string) error
- func (r *DockerHelper) WaitContainerRunning(ctx context.Context, containerID string) error
- type Elevator
- type PullOptions
- type RuntimeName
- type Streams
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func LoadDockerConfig ¶
func LoadDockerConfig() (*configfile.ConfigFile, error)
func PrepareForGroupCancellation ¶
PrepareForGroupCancellation sets the Cancel function of the given exec.Cmd to kill the entire process group, allowing for cleanup of child processes. This is necessary because exec.Cmd does not automatically kill child processes when the context is canceled.
Types ¶
type ContainerRuntime ¶ added in v1.1.0
type ContainerRuntime interface {
Name() RuntimeName
SupportsInternalBuildKit() bool
SupportsSignalProxy() bool
SupportsMountConsistency() bool
NeedsUserNamespaceArgs() bool
GPUAvailable(ctx context.Context, helper *DockerHelper) (bool, error)
}
ContainerRuntime describes the capabilities of a container runtime (Docker, Podman, nerdctl). Rather than checking IsPodman()/IsNerdctl() at every call site, callers query capability methods that express *why* the code branches.
func DetectRuntime ¶ added in v1.1.0
func DetectRuntime(dockerCommand string) ContainerRuntime
DetectRuntime probes the binary at dockerCommand to determine which runtime it is. The result is cached per binary path.
func RuntimeFromName ¶ added in v1.1.0
func RuntimeFromName(name string) (ContainerRuntime, error)
RuntimeFromName returns a ContainerRuntime for the given explicit name. Empty string defaults to Docker. Unknown non-empty names return an error to catch typos in provider configuration.
type DockerBuilder ¶
type DockerBuilder int
DockerBuilder represents the Docker builder types.
const ( DockerBuilderDefault DockerBuilder = iota DockerBuilderBuildX DockerBuilderBuildKit )
Enum values for DockerBuilder.
func DockerBuilderFromString ¶
func DockerBuilderFromString(s string) (DockerBuilder, error)
func (DockerBuilder) String ¶
func (db DockerBuilder) String() string
type DockerHelper ¶
type DockerHelper struct {
DockerCommand string
// for a running container, we cannot pass down the container ID to the driver without introducing
// changes in the driver interface (which we do not want to do). So, to get around this, we pass
// it down to the driver during docker helper initialization.
ContainerID string
// allow command to have a custom environment
Environment []string
Builder DockerBuilder
Runtime ContainerRuntime
// Elevator, when set, runs docker commands through a privilege-elevation
// helper (pkexec/sudo/doas). Nil disables elevation.
Elevator *Elevator
}
func (*DockerHelper) ClientVersion ¶ added in v1.3.1
func (r *DockerHelper) ClientVersion(ctx context.Context) string
ClientVersion returns the docker CLI version (e.g. "29.5.3"), or "".
func (*DockerHelper) DeleteVolume ¶
func (r *DockerHelper) DeleteVolume(ctx context.Context, volume string) error
func (*DockerHelper) EnsureElevated ¶ added in v1.10.0
func (r *DockerHelper) EnsureElevated() error
EnsureElevated authenticates the configured elevator once; concurrent callers block on the single prompt. No-op and safe when no elevator is set.
func (*DockerHelper) FindContainer ¶
FindContainer will try to find a container based on the input labels. If no container is found, it will search for the labels manually inspecting containers.
func (*DockerHelper) FindContainerByID ¶
func (r *DockerHelper) FindContainerByID( ctx context.Context, containerIds []string, ) (*config.ContainerDetails, error)
func (*DockerHelper) FindContainerJSON ¶
FindContainerJSON will manually search for containers with matching labels. This is useful in case the `--filter` doesn't work.
func (*DockerHelper) FindDevContainer ¶
func (r *DockerHelper) FindDevContainer( ctx context.Context, labels []string, ) (*config.ContainerDetails, error)
func (*DockerHelper) GPUSupportEnabled ¶
func (r *DockerHelper) GPUSupportEnabled() (bool, error)
func (*DockerHelper) GetContainerLogs ¶
func (*DockerHelper) GetImageTag ¶
func (*DockerHelper) GetRuntime ¶ added in v1.1.0
func (r *DockerHelper) GetRuntime() ContainerRuntime
GetRuntime returns the container runtime for this helper. If no runtime was explicitly set, it auto-detects from the docker command.
func (*DockerHelper) InspectContainers ¶
func (r *DockerHelper) InspectContainers( ctx context.Context, ids []string, ) ([]config.ContainerDetails, error)
func (*DockerHelper) InspectImage ¶
func (r *DockerHelper) InspectImage( ctx context.Context, imageName string, tryRemote bool, ) (*config.ImageDetails, error)
func (*DockerHelper) IsNerdctl ¶
func (r *DockerHelper) IsNerdctl() bool
func (*DockerHelper) IsPodman ¶
func (r *DockerHelper) IsPodman() bool
func (*DockerHelper) LingerWarning ¶ added in v1.5.1
func (r *DockerHelper) LingerWarning(ctx context.Context) string
func (*DockerHelper) Ping ¶ added in v1.11.0
func (r *DockerHelper) Ping(ctx context.Context) error
Ping reports whether the runtime daemon is reachable, returning its own message (e.g. "Cannot connect to Podman") on failure. It runs a bare `info` and judges reachability by exit status: `--format` field names differ between docker (.ServerVersion) and podman/nerdctl, so a shared template would falsely fail non-docker runtimes.
func (*DockerHelper) PodmanMachineExists ¶
func (r *DockerHelper) PodmanMachineExists(ctx context.Context) (bool, error)
PodmanMachineExists reports whether a Podman machine exists.
func (*DockerHelper) Pull ¶
func (r *DockerHelper) Pull(ctx context.Context, opts PullOptions) error
func (*DockerHelper) RunWithDir ¶
func (*DockerHelper) RunWithEnv ¶ added in v1.10.0
func (r *DockerHelper) RunWithEnv( ctx context.Context, extraEnv []string, args []string, streams Streams, ) error
RunWithEnv runs a command with extra environment variables for this invocation only (used for env-backed buildx secrets).
func (*DockerHelper) StartContainer ¶
func (r *DockerHelper) StartContainer(ctx context.Context, containerId string) error
func (*DockerHelper) StartPodmanMachine ¶ added in v1.11.0
func (r *DockerHelper) StartPodmanMachine(ctx context.Context) error
StartPodmanMachine starts the default Podman machine, which must already exist.
func (*DockerHelper) StartRootlessPodmanSocket ¶
func (r *DockerHelper) StartRootlessPodmanSocket(ctx context.Context) error
StartRootlessPodmanSocket starts the podman.socket systemd unit for rootless Podman.
func (*DockerHelper) WaitContainerRunning ¶
func (r *DockerHelper) WaitContainerRunning(ctx context.Context, containerID string) error
WaitContainerRunning waits for the given container to be running, returning an error if it is in a terminal state or does not become running within a timeout.
type Elevator ¶ added in v1.10.0
type Elevator struct {
// contains filtered or unexported fields
}
Elevator runs docker commands through a privilege-elevation helper (pkexec, sudo, doas). It authenticates once, up front, so an operation's many commands share a single prompt via the warmed OS credential cache.
func ElevatorFromName ¶ added in v1.10.0
ElevatorFromName maps a helper name to an Elevator; "" and "none" return (nil, nil), unknown names error.
type PullOptions ¶ added in v1.3.1
type PullOptions struct {
Image string
Platform string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
PullOptions configures an image pull.
type RuntimeName ¶ added in v1.1.0
type RuntimeName string
RuntimeName identifies a container runtime.
const ( RuntimeDocker RuntimeName = "docker" RuntimePodman RuntimeName = "podman" RuntimeNerdctl RuntimeName = "nerdctl" )