Documentation
¶
Overview ¶
Package docker is internal
Index ¶
- Constants
- Variables
- func ConfigsEqual(a, b *DaemonConfig) bool
- func DaemonConfigExists(client ssh.Connection) (bool, error)
- func RestartDockerDaemon(client ssh.Connection) error
- func WaitForDockerReady(client ssh.Connection, timeout time.Duration) error
- func WriteDaemonConfig(client ssh.Connection, config *DaemonConfig) error
- type ContainerRunOptions
- type DaemonConfig
- type Executor
- func (*Executor) ContainerExists(client ssh.Connection, containerName string) (bool, error)
- func (e *Executor) CreateNetwork(client ssh.Connection, networkName, driver string, labels map[string]string) error
- func (e *Executor) CreateVolume(client ssh.Connection, volumeName, driver string, labels map[string]string) error
- func (*Executor) GetContainerLabel(client ssh.Connection, containerName, labelKey string) (string, error)
- func (*Executor) GetNetworkLabel(client ssh.Connection, networkName, labelKey string) (string, error)
- func (*Executor) GetVolumeLabel(client ssh.Connection, volumeName, labelKey string) (string, error)
- func (*Executor) NetworkExists(client ssh.Connection, networkName string) (bool, error)
- func (e *Executor) PullImage(client ssh.Connection, image string) (bool, error)
- func (e *Executor) RegistryLogin(client ssh.Connection, registry, username, password string) error
- func (e *Executor) RemoveContainer(client ssh.Connection, containerName string, force bool) error
- func (e *Executor) RemoveNetwork(client ssh.Connection, networkName string) error
- func (e *Executor) RemoveVolume(client ssh.Connection, volumeName string) error
- func (e *Executor) RunContainer(client ssh.Connection, opts ContainerRunOptions) error
- func (e *Executor) StopContainer(client ssh.Connection, containerName string) error
- func (e *Executor) UploadDataMount(client ssh.Connection, data []byte) (string, error)
- func (e *Executor) UploadMount(client ssh.Connection, localPath string) (string, error)
- func (*Executor) VolumeExists(client ssh.Connection, volumeName string) (bool, error)
- type UlimitConfig
- type VolumeMount
Constants ¶
const ( // PermSecretFile is the permission for secret files (owner read/write only). // Used for sensitive data like credentials, keys, and configuration secrets. PermSecretFile os.FileMode = filesystem.FilePermissionsPrivate // PermPublicFile is the permission for public files (owner read/write, others read). // Used for non-sensitive data that containers need to read. PermPublicFile os.FileMode = filesystem.FilePermissionsDefault // PermSecretDir is the permission for secret directories (owner read/write/execute only). // Used for directories containing sensitive data. PermSecretDir os.FileMode = filesystem.DirPermissionsPrivate )
File permission constants for Docker operations.
Variables ¶
var ( // ErrFileSystemWalk indicates failure while walking directory tree. ErrFileSystemWalk = errors.New("failed to walk directory tree") // ErrPathRelative indicates failure to compute relative path. ErrPathRelative = errors.New("failed to compute relative path") )
Functions ¶
func ConfigsEqual ¶
func ConfigsEqual(a, b *DaemonConfig) bool
ConfigsEqual checks if two daemon configs are equivalent.
func DaemonConfigExists ¶
func DaemonConfigExists(client ssh.Connection) (bool, error)
DaemonConfigExists checks if /etc/docker/daemon.json exists.
func RestartDockerDaemon ¶
func RestartDockerDaemon(client ssh.Connection) error
RestartDockerDaemon restarts the Docker daemon.
func WaitForDockerReady ¶
func WaitForDockerReady(client ssh.Connection, timeout time.Duration) error
WaitForDockerReady waits for Docker daemon to be ready after restart.
func WriteDaemonConfig ¶
func WriteDaemonConfig(client ssh.Connection, config *DaemonConfig) error
WriteDaemonConfig writes the daemon configuration to /etc/docker/daemon.json.
Types ¶
type ContainerRunOptions ¶
type ContainerRunOptions struct {
Name string
Image string
Command []string // optional command arguments to append after image
User string // user:group or UID:GID
Memory string // memory limit (e.g., "512m", "2g")
MemoryReservation string // memory soft limit
CPUs string // hard CPU limit (e.g., "1.5" for 1.5 CPUs)
PIDsLimit int64 // maximum number of PIDs (process limit)
Hostname string // container hostname
Network string
NetworkAlias string
Ports []string
ExtraHosts []string // extra host:ip mappings
Volumes []VolumeMount
Tmpfs map[string]string // mount point -> options
EnvFile string
EnvVars map[string]string
Restart string
ReadOnly bool
SecurityOpts []string
CapDrop []string
CapAdd []string
GroupAdd []string // additional groups for the container user
Labels map[string]string
}
ContainerRunOptions represents options for running a container.
type DaemonConfig ¶
type DaemonConfig struct {
LiveRestore bool `json:"live-restore"`
UserlandProxy bool `json:"userland-proxy"`
NoNewPrivileges bool `json:"no-new-privileges"`
ICC bool `json:"icc"`
BIP string `json:"bip,omitempty"` // Bridge IP (docker0 network)
LogDriver string `json:"log-driver"`
LogOpts map[string]string `json:"log-opts"`
DefaultUlimits map[string]UlimitConfig `json:"default-ulimits"`
}
DaemonConfig represents the Docker daemon configuration.
func GetDaemonConfig ¶
func GetDaemonConfig(client ssh.Connection) (*DaemonConfig, error)
GetDaemonConfig reads the current daemon configuration.
func GetSecureDefaults ¶
func GetSecureDefaults() *DaemonConfig
GetSecureDefaults returns the recommended secure Docker daemon configuration.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes Docker commands on remote hosts via SSH.
func NewExecutor ¶
NewExecutor creates a new Docker command executor.
func (*Executor) ContainerExists ¶
ContainerExists checks if a Docker container exists on the remote host.
func (*Executor) CreateNetwork ¶
func (e *Executor) CreateNetwork(client ssh.Connection, networkName, driver string, labels map[string]string) error
CreateNetwork creates a Docker network on the remote host.
func (*Executor) CreateVolume ¶
func (e *Executor) CreateVolume(client ssh.Connection, volumeName, driver string, labels map[string]string) error
CreateVolume creates a Docker volume on the remote host.
func (*Executor) GetContainerLabel ¶
func (*Executor) GetContainerLabel(client ssh.Connection, containerName, labelKey string) (string, error)
GetContainerLabel retrieves a label value from a container.
func (*Executor) GetNetworkLabel ¶
func (*Executor) GetNetworkLabel(client ssh.Connection, networkName, labelKey string) (string, error)
GetNetworkLabel retrieves a label value from a network.
func (*Executor) GetVolumeLabel ¶
GetVolumeLabel retrieves a label value from a volume.
func (*Executor) NetworkExists ¶
NetworkExists checks if a Docker network exists on the remote host.
func (*Executor) PullImage ¶
PullImage pulls the latest version of an image and returns true if a new image was pulled. Returns false if the image was already up to date (nothing to pull).
func (*Executor) RegistryLogin ¶
func (e *Executor) RegistryLogin(client ssh.Connection, registry, username, password string) error
RegistryLogin logs into a Docker registry on the remote host.
func (*Executor) RemoveContainer ¶
RemoveContainer removes a Docker container.
func (*Executor) RemoveNetwork ¶
func (e *Executor) RemoveNetwork(client ssh.Connection, networkName string) error
RemoveNetwork removes a Docker network from the remote host.
func (*Executor) RemoveVolume ¶
func (e *Executor) RemoveVolume(client ssh.Connection, volumeName string) error
RemoveVolume removes a Docker volume from the remote host.
func (*Executor) RunContainer ¶
func (e *Executor) RunContainer(client ssh.Connection, opts ContainerRunOptions) error
RunContainer runs a Docker container on the remote host.
func (*Executor) StopContainer ¶
func (e *Executor) StopContainer(client ssh.Connection, containerName string) error
StopContainer stops a Docker container.
func (*Executor) UploadDataMount ¶
UploadDataMount uploads raw data as a file to the remote host if it doesn't already exist. Uses content-addressable storage (SHA256 hash) to avoid duplicates. Returns the remote path.
func (*Executor) UploadMount ¶
UploadMount uploads a local file or directory to the remote host if it doesn't already exist. Returns the remote path.
func (*Executor) VolumeExists ¶
VolumeExists checks if a Docker volume exists on the remote host.
type UlimitConfig ¶
type UlimitConfig struct {
Name string `json:"Name"`
Hard int `json:"Hard"`
Soft int `json:"Soft"`
}
UlimitConfig represents a ulimit configuration.
type VolumeMount ¶
VolumeMount represents a volume mount for docker run.