Documentation
¶
Index ¶
- Variables
- func LoadDockerConfig() (*configfile.ConfigFile, error)
- type Client
- type ContainerRuntime
- type DockerBuilder
- type DockerHelper
- func (r *DockerHelper) DeleteVolume(ctx context.Context, volume string) 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) Pull(ctx context.Context, image string, stdin io.Reader, stdout io.Writer, ...) error
- func (r *DockerHelper) Remove(ctx context.Context, id string) error
- func (r *DockerHelper) Run(ctx context.Context, args []string, stdin io.Reader, stdout io.Writer, ...) error
- func (r *DockerHelper) RunWithDir(ctx context.Context, dir string, args []string, stdin io.Reader, ...) error
- func (r *DockerHelper) StartContainer(ctx context.Context, containerId string) error
- func (r *DockerHelper) Stop(ctx context.Context, id string) error
- func (r *DockerHelper) WaitContainerRunning(ctx context.Context, containerID string) error
- type RuntimeName
Constants ¶
This section is empty.
Variables ¶
var ErrContainerTerminal = errors.New("container in terminal state")
ErrContainerTerminal indicates a container entered an unrecoverable state (e.g. "dead" or "removing") and cannot be restarted.
Functions ¶
func LoadDockerConfig ¶
func LoadDockerConfig() (*configfile.ConfigFile, error)
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
}
func (*DockerHelper) DeleteVolume ¶
func (r *DockerHelper) DeleteVolume(ctx context.Context, volume string) error
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) RunWithDir ¶
func (*DockerHelper) StartContainer ¶
func (r *DockerHelper) StartContainer(ctx context.Context, containerId string) error
func (*DockerHelper) WaitContainerRunning ¶
func (r *DockerHelper) WaitContainerRunning(ctx context.Context, containerID string) error
WaitContainerRunning polls docker inspect until the container reports status "running" or the context/timeout expires. It does not start the container — the caller is responsible for that.
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" )