Help us shape the future of Go! Take the 2026 Go Developer Survey

docker

package
v1.6.112 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: MPL-2.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoSuchContainerError is returned by the docker daemon if the container
	// does not exist.
	NoSuchContainerError = "No such container"

	// ContainerNotRunningError is returned by the docker daemon if the container
	// is not running, yet we requested it to stop
	ContainerNotRunningError = "Container not running"
)

Variables

View Source
var (
	// PluginID is the docker plugin metadata registered in the plugin catalog.
	PluginID = loader.PluginID{
		Name:       pluginName,
		PluginType: base.PluginTypeDriver,
	}

	// PluginConfig is the docker config factory function registered in the plugin catalog.
	PluginConfig = &loader.InternalPluginConfig{
		Config:  map[string]interface{}{},
		Factory: func(ctx context.Context, l hclog.Logger) interface{} { return NewDockerDriver(ctx, l) },
	}
)

Functions

func NewDockerDriver

func NewDockerDriver(ctx context.Context, logger hclog.Logger) drivers.DriverPlugin

NewDockerDriver returns a docker implementation of a driver plugin

func PluginLoader

func PluginLoader(opts map[string]string) (map[string]interface{}, error)

Types

type AuthConfig

type AuthConfig struct {
	Config string `codec:"config"`
	Helper string `codec:"helper"`
}

type ContainerGCConfig added in v0.10.2

type ContainerGCConfig struct {
	// Enabled controls whether container reconciler is enabled
	Enabled bool `codec:"enabled"`

	// DryRun indicates that reconciler should log unexpectedly running containers
	// if found without actually killing them
	DryRun bool `codec:"dry_run"`

	// PeriodStr controls the frequency of scanning containers
	PeriodStr string `codec:"period"`

	// CreationGraceStr is the duration allowed for a newly created container
	// to live without being registered as a running task in nomad.
	// A container is treated as leaked if it lived more than grace duration
	// and haven't been registered in tasks.
	CreationGraceStr string        `codec:"creation_grace"`
	CreationGrace    time.Duration `codec:"-"`
	// contains filtered or unexported fields
}

ContainerGCConfig controls the behavior of the GC reconciler to detects dangling nomad containers that aren't tracked due to docker/nomad bugs

type CpusetFixer added in v1.6.105

type CpusetFixer interface {
	Start()
}

type DockerAuth

type DockerAuth struct {
	Username   string `codec:"username"`
	Password   string `codec:"password"`
	Email      string `codec:"email"`
	ServerAddr string `codec:"server_address"`
}

type DockerBindOptions

type DockerBindOptions struct {
	Propagation string `codec:"propagation"`
}

type DockerDevice

type DockerDevice struct {
	HostPath          string `codec:"host_path"`
	ContainerPath     string `codec:"container_path"`
	CgroupPermissions string `codec:"cgroup_permissions"`
}

type DockerHealthchecks added in v1.6.105

type DockerHealthchecks struct {
	Disable bool `codec:"disable"`
}

func (*DockerHealthchecks) Disabled added in v1.6.105

func (dh *DockerHealthchecks) Disabled() bool

type DockerImageClient

type DockerImageClient interface {
	PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
	InspectImage(id string) (*docker.Image, error)
	RemoveImageExtended(id string, opts docker.RemoveImageOptions) error
}

DockerImageClient provides the methods required to do CRUD operations on the Docker images

type DockerLogging

type DockerLogging struct {
	Type   string             `codec:"type"`
	Driver string             `codec:"driver"`
	Config hclutils.MapStrStr `codec:"config"`
}

type DockerMount

type DockerMount struct {
	Type          string              `codec:"type"`
	Target        string              `codec:"target"`
	Source        string              `codec:"source"`
	ReadOnly      bool                `codec:"readonly"`
	BindOptions   DockerBindOptions   `codec:"bind_options"`
	VolumeOptions DockerVolumeOptions `codec:"volume_options"`
	TmpfsOptions  DockerTmpfsOptions  `codec:"tmpfs_options"`
}

type DockerTmpfsOptions

type DockerTmpfsOptions struct {
	SizeBytes int64 `codec:"size"`
	Mode      int   `codec:"mode"`
}

type DockerVolumeDriverConfig

type DockerVolumeDriverConfig struct {
	Name    string             `codec:"name"`
	Options hclutils.MapStrStr `codec:"options"`
}

DockerVolumeDriverConfig holds a map of volume driver specific options

type DockerVolumeOptions

type DockerVolumeOptions struct {
	NoCopy       bool                     `codec:"no_copy"`
	Labels       hclutils.MapStrStr       `codec:"labels"`
	DriverConfig DockerVolumeDriverConfig `codec:"driver_config"`
}

type Driver

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

func (*Driver) Capabilities

func (d *Driver) Capabilities() (*drivers.Capabilities, error)

Capabilities is returned by the Capabilities RPC and indicates what optional features this driver supports.

func (*Driver) ConfigSchema

func (d *Driver) ConfigSchema() (*hclspec.Spec, error)

func (*Driver) CreateNetwork added in v0.10.0

func (d *Driver) CreateNetwork(allocID string, createSpec *drivers.NetworkCreateRequest) (*drivers.NetworkIsolationSpec, bool, error)

func (*Driver) DestroyNetwork added in v0.10.0

func (d *Driver) DestroyNetwork(allocID string, spec *drivers.NetworkIsolationSpec) error

func (*Driver) DestroyTask

func (d *Driver) DestroyTask(taskID string, force bool) error

func (*Driver) ExecTask

func (d *Driver) ExecTask(taskID string, cmd []string, timeout time.Duration) (*drivers.ExecTaskResult, error)

func (*Driver) ExecTaskStreaming added in v0.9.2

func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts *drivers.ExecOptions) (*drivers.ExitResult, error)

func (*Driver) Fingerprint

func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint, error)

func (*Driver) InspectTask

func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error)

func (*Driver) PluginInfo

func (d *Driver) PluginInfo() (*base.PluginInfoResponse, error)

func (*Driver) RecoverTask

func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error

func (*Driver) SetConfig

func (d *Driver) SetConfig(c *base.Config) error

func (*Driver) SignalTask

func (d *Driver) SignalTask(taskID string, signal string) error

func (*Driver) StartTask

func (*Driver) StopTask

func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error

func (*Driver) TaskConfigSchema

func (d *Driver) TaskConfigSchema() (*hclspec.Spec, error)

func (*Driver) TaskEvents

func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error)

func (*Driver) TaskStats

func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error)

func (*Driver) WaitTask

func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error)

type DriverConfig

type DriverConfig struct {
	Endpoint              string       `codec:"endpoint"`
	Auth                  AuthConfig   `codec:"auth"`
	TLS                   TLSConfig    `codec:"tls"`
	GC                    GCConfig     `codec:"gc"`
	Volumes               VolumeConfig `codec:"volumes"`
	AllowPrivileged       bool         `codec:"allow_privileged"`
	AllowCaps             []string     `codec:"allow_caps"`
	GPURuntimeName        string       `codec:"nvidia_runtime"`
	InfraImage            string       `codec:"infra_image"`
	InfraImagePullTimeout string       `codec:"infra_image_pull_timeout"`

	DisableLogCollection bool   `codec:"disable_log_collection"`
	PullActivityTimeout  string `codec:"pull_activity_timeout"`
	PidsLimit            int64  `codec:"pids_limit"`

	ExtraLabels []string      `codec:"extra_labels"`
	Logging     LoggingConfig `codec:"logging"`

	AllowRuntimesList []string `codec:"allow_runtimes"`
	// contains filtered or unexported fields
}

type GCConfig

type GCConfig struct {
	Image      bool   `codec:"image"`
	ImageDelay string `codec:"image_delay"`

	Container bool `codec:"container"`

	DanglingContainers ContainerGCConfig `codec:"dangling_containers"`
	// contains filtered or unexported fields
}

type LogEventFn

type LogEventFn func(message string, annotations map[string]string)

LogEventFn is a callback which allows Drivers to emit task events.

type LoggingConfig added in v1.6.105

type LoggingConfig struct {
	Type   string            `codec:"type"`
	Config map[string]string `codec:"config"`
}

type TLSConfig

type TLSConfig struct {
	Cert string `codec:"cert"`
	Key  string `codec:"key"`
	CA   string `codec:"ca"`
}

type TaskConfig

type TaskConfig struct {
	Image             string             `codec:"image"`
	AdvertiseIPv6Addr bool               `codec:"advertise_ipv6_address"`
	Args              []string           `codec:"args"`
	Auth              DockerAuth         `codec:"auth"`
	AuthSoftFail      bool               `codec:"auth_soft_fail"`
	CapAdd            []string           `codec:"cap_add"`
	CapDrop           []string           `codec:"cap_drop"`
	Command           string             `codec:"command"`
	CPUCFSPeriod      int64              `codec:"cpu_cfs_period"`
	CPUHardLimit      bool               `codec:"cpu_hard_limit"`
	CPUSetCPUs        string             `codec:"cpuset_cpus"`
	Devices           []DockerDevice     `codec:"devices"`
	DNSSearchDomains  []string           `codec:"dns_search_domains"`
	DNSOptions        []string           `codec:"dns_options"`
	DNSServers        []string           `codec:"dns_servers"`
	Entrypoint        []string           `codec:"entrypoint"`
	ExtraHosts        []string           `codec:"extra_hosts"`
	ForcePull         bool               `codec:"force_pull"`
	GroupAdd          []string           `codec:"group_add"`
	Healthchecks      DockerHealthchecks `codec:"healthchecks"`
	Hostname          string             `codec:"hostname"`
	Init              bool               `codec:"init"`
	Interactive       bool               `codec:"interactive"`
	IPCMode           string             `codec:"ipc_mode"`
	IPv4Address       string             `codec:"ipv4_address"`
	IPv6Address       string             `codec:"ipv6_address"`
	Isolation         string             `codec:"isolation"`
	Labels            hclutils.MapStrStr `codec:"labels"`
	LoadImage         string             `codec:"load"`
	Logging           DockerLogging      `codec:"logging"`
	MacAddress        string             `codec:"mac_address"`
	MemoryHardLimit   int64              `codec:"memory_hard_limit"`
	Mounts            []DockerMount      `codec:"mount"`
	NetworkAliases    []string           `codec:"network_aliases"`
	NetworkMode       string             `codec:"network_mode"`
	Runtime           string             `codec:"runtime"`
	PidsLimit         int64              `codec:"pids_limit"`
	PidMode           string             `codec:"pid_mode"`
	Ports             []string           `codec:"ports"`
	PortMap           hclutils.MapStrInt `codec:"port_map"`
	Privileged        bool               `codec:"privileged"`
	ImagePullTimeout  string             `codec:"image_pull_timeout"`
	ReadonlyRootfs    bool               `codec:"readonly_rootfs"`
	SecurityOpt       []string           `codec:"security_opt"`
	ShmSize           int64              `codec:"shm_size"`
	StorageOpt        map[string]string  `codec:"storage_opt"`
	Sysctl            hclutils.MapStrStr `codec:"sysctl"`
	TTY               bool               `codec:"tty"`
	Ulimit            hclutils.MapStrStr `codec:"ulimit"`
	UTSMode           string             `codec:"uts_mode"`
	UsernsMode        string             `codec:"userns_mode"`
	Volumes           []string           `codec:"volumes"`
	VolumeDriver      string             `codec:"volume_driver"`
	WorkDir           string             `codec:"work_dir"`

	// MountsList supports the pre-1.0 mounts array syntax
	MountsList []DockerMount `codec:"mounts"`
}

type VolumeConfig

type VolumeConfig struct {
	Enabled      bool   `codec:"enabled"`
	SelinuxLabel string `codec:"selinuxlabel"`
}

Directories

Path Synopsis
This package provides a mechanism to build the Docker driver plugin as an external binary.
This package provides a mechanism to build the Docker driver plugin as an external binary.

Jump to

Keyboard shortcuts

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