docker

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerWorkingDir is the default working directory inside containers.
	ContainerWorkingDir = "/workspace"
	// DirPermission is the default permission for directories.
	DirPermission os.FileMode = 0o775
	// FilePermission is the default permission for files.
	FilePermission os.FileMode = 0o644
)

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst.

func IsPodman

func IsPodman(ctx context.Context, logger *slog.Logger) bool

IsPodman checks if Docker is actually Podman.

func RedactSecrets

func RedactSecrets(s string, env map[string]string) string

RedactSecrets replaces secret values in a string with <REDACTED>.

Types

type Config

type Config struct {
	Name       string
	Image      string
	WorkingDir string
	// Dockerfile is the file name under docker/ used to build the image.
	// If empty, "Dockerfile" is used.
	Dockerfile string
}

Config holds Docker container configuration.

func DefaultAlpineContainer added in v0.5.2

func DefaultAlpineContainer() Config

DefaultAlpineContainer returns the default Alpine (musl) Linux container configuration. It is used when registry.yaml contains packages with `key: libc` variants to verify both musl and gnu libc paths.

func DefaultLinuxContainer

func DefaultLinuxContainer() Config

DefaultLinuxContainer returns the default Linux container configuration.

func DefaultWindowsContainer

func DefaultWindowsContainer() Config

DefaultWindowsContainer returns the default Windows container configuration.

type Manager

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

Manager manages Docker container operations.

func NewManager

func NewManager(config Config) *Manager

NewManager creates a new Manager with the given configuration.

func (*Manager) Command

func (dm *Manager) Command(ctx context.Context, logger *slog.Logger, env map[string]string, command ...string) *exec.Cmd

Command executes a command in the container.

func (*Manager) Config

func (dm *Manager) Config() Config

Config returns the container configuration.

func (*Manager) ContainerExists

func (dm *Manager) ContainerExists(ctx context.Context, logger *slog.Logger) (bool, error)

ContainerExists checks if the container exists.

func (*Manager) ContainerRunning

func (dm *Manager) ContainerRunning(ctx context.Context, logger *slog.Logger) (bool, error)

ContainerRunning checks if the container is running.

func (*Manager) CopyFrom

func (dm *Manager) CopyFrom(ctx context.Context, logger *slog.Logger, src, dst string) error

CopyFrom copies a file from the container to the host.

func (*Manager) CopyTo

func (dm *Manager) CopyTo(ctx context.Context, logger *slog.Logger, src, dst string) error

CopyTo copies a file from the host to the container.

func (*Manager) EnsureContainer

func (dm *Manager) EnsureContainer(ctx context.Context, logger *slog.Logger, recreate bool) error

EnsureContainer ensures the container is running. If recreate is true, it will stop and remove the existing container first.

func (*Manager) ExecBash

func (dm *Manager) ExecBash(ctx context.Context, logger *slog.Logger, bashCmd string) error

ExecBash executes a bash command in the container.

func (*Manager) ExecInteractive

func (dm *Manager) ExecInteractive(ctx context.Context, logger *slog.Logger, env map[string]string, command ...string) error

ExecInteractive executes an interactive command in the container with stdin attached.

func (*Manager) RemoveContainer

func (dm *Manager) RemoveContainer(ctx context.Context, logger *slog.Logger) error

RemoveContainer stops and removes the container.

func (*Manager) StopContainer

func (dm *Manager) StopContainer(ctx context.Context, logger *slog.Logger) error

StopContainer stops the container if it is running.

Jump to

Keyboard shortcuts

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