docker

package
v0.0.0-...-0eb8750 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const LabelKeyCategory string = "category"
View Source
const LabelKeyIfaceType string = "ifacetype"
View Source
const LabelKeyInstance string = "instance"
View Source
const LabelKeyService string = "service"

Variables

This section is empty.

Functions

func FindContainer

func FindContainer(ctx context.Context, cli *client.Client, containerName string) (*container.Summary, error)

If no container is found, return (nil, nil), by default, it expects exact match

func GetContainerDisplayName

func GetContainerDisplayName(containerName *string) string

func GetContainerNSPid

func GetContainerNSPid(ctx context.Context, cli *client.Client, containerName string) (*int, error)

func GetNetNSHandle

func GetNetNSHandle(ctx context.Context, cli *client.Client, containerName string) (netns.NsHandle, error)

func IsRegularContainerName

func IsRegularContainerName(containerName string) bool

func StopAndRemoveContainer

func StopAndRemoveContainer(ctx context.Context, containerName string) error

func WithNetnsWGCli

func WithNetnsWGCli(ctx context.Context, containerName *string, hook func(wgCtrlCli *wgctrl.Client) error) error

func WithNsHandle

func WithNsHandle(ctx context.Context, containerName *string, f func(h *netlink.Handle) error) error

func WithNsHandleSafe

func WithNsHandleSafe(ctx context.Context, containerName *string, f func(h *netlink.Handle) error) error

Types

type ContainerConfig

type ContainerConfig struct {
	Docker ContainerDockerConfig `yaml:"docker,omitempty" json:"docker,omitempty"`
}

type ContainerDockerConfig

type ContainerDockerConfig struct {
	Name string `yaml:"name" json:"name"`
}

type ContainerKey

type ContainerKey string
const (
	ContainerKeyHost ContainerKey = "-"
)

func GetContainerKey

func GetContainerKey(containerName *string) ContainerKey

type ContainerList

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

func NewContainerListFromServiceName

func NewContainerListFromServiceName(ctx context.Context, serviceName string) (*ContainerList, error)

func (*ContainerList) GetContainers

func (containerList *ContainerList) GetContainers() []container.Summary

type DockerContainerConfig

type DockerContainerConfig struct {
	Image         string                         `yaml:"image" json:"image"`
	ContainerName string                         `yaml:"container_name,omitempty" json:"container_name,omitempty"`
	Capabilities  []string                       `yaml:"cap_add,omitempty" json:"cap_add,omitempty"`
	Hostname      *string                        `yaml:"hostname,omitempty" json:"hostname,omitempty"`
	Ports         map[string][]DockerPortMapping `yaml:"ports,omitempty" json:"ports,omitempty"`
	Volumes       []DockerMountConfig            `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	Devices       []DockerDeviceMapping          `yaml:"devices,omitempty" json:"devices,omitempty"`
	AutoRemove    *bool                          `yaml:"autoremove,omitempty" json:"autoremove,omitempty"`
	Networks      []string                       `yaml:"networks,omitempty" json:"networks,omitempty"`
	Command       []string                       `yaml:"command,omitempty" json:"command,omitempty"`
	Labels        map[string]string              `yaml:"labels,omitempty" json:"labels,omitempty"`
	TTY           *bool                          `yaml:"tty,omitempty" json:"tty,omitempty"`
	OpenStdin     *bool                          `yaml:"stdin_open,omitempty" json:"stdin_open,omitempty"`
}

func (*DockerContainerConfig) Apply

func (dockerConfig *DockerContainerConfig) Apply(ctx context.Context) error

func (*DockerContainerConfig) ApplyToContainerCreateConfig

func (dockerConfig *DockerContainerConfig) ApplyToContainerCreateConfig(
	containerConfig *container.Config,
	hostConfig *container.HostConfig,
	networkConfig *network.NetworkingConfig,
)

func (*DockerContainerConfig) Create

func (dockerConfig *DockerContainerConfig) Create(ctx context.Context) error

func (*DockerContainerConfig) ReCreate

func (dockerConfig *DockerContainerConfig) ReCreate(ctx context.Context) error

type DockerDeviceMapping

type DockerDeviceMapping struct {
	// For example, "/dev/net/tun"
	PathOnHost string `yaml:"path_on_host" json:"path_on_host"`

	// For example, "/dev/net/tun"
	PathInContainer string `yaml:"path_in_container" json:"path_in_container"`

	// Should use "rwm" mostly
	CgroupPermissions *string `yaml:"cgroup_permissions,omitempty" json:"cgroup_permissions,omitempty"`
}

type DockerMountConfig

type DockerMountConfig struct {
	Type   mount.Type `yaml:"type" json:"type"`
	Source string     `yaml:"source" json:"source"`
	Target string     `yaml:"target" json:"target"`
}

type DockerPortMapping

type DockerPortMapping struct {
	HostIP   string `yaml:"host_ip" json:"host_ip"`
	HostPort int    `yaml:"host_port" json:"host_port"`
}

Jump to

Keyboard shortcuts

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