docker

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WildcardAlias = "*"

	NSProxy = "proxy"

	LabelAliases       = NSProxy + ".aliases"
	LabelExclude       = NSProxy + ".exclude"
	LabelIdleTimeout   = NSProxy + ".idle_timeout"
	LabelWakeTimeout   = NSProxy + ".wake_timeout"
	LabelStopMethod    = NSProxy + ".stop_method"
	LabelStopTimeout   = NSProxy + ".stop_timeout"
	LabelStopSignal    = NSProxy + ".stop_signal"
	LabelStartEndpoint = NSProxy + ".start_endpoint"
)

Variables

View Source
var DummyContainer = new(Container)
View Source
var ErrInvalidLabel = E.New("invalid label")

Functions

func IsErrConnectionFailed

func IsErrConnectionFailed(err error) bool

func ListContainers

func ListContainers(clientHost string) ([]types.Container, error)

Types

type Container

type Container struct {
	DockerHost    string `json:"docker_host"`
	ContainerName string `json:"container_name"`
	ContainerID   string `json:"container_id"`
	ImageName     string `json:"image_name"`

	Labels map[string]string `json:"-"`

	PublicPortMapping  PortMapping `json:"public_ports"`  // non-zero publicPort:types.Port
	PrivatePortMapping PortMapping `json:"private_ports"` // privatePort:types.Port
	PublicIP           string      `json:"public_ip"`
	PrivateIP          string      `json:"private_ip"`
	NetworkMode        string      `json:"network_mode"`

	Aliases       []string `json:"aliases"`
	IsExcluded    bool     `json:"is_excluded"`
	IsExplicit    bool     `json:"is_explicit"`
	IsDatabase    bool     `json:"is_database"`
	IdleTimeout   string   `json:"idle_timeout,omitempty"`
	WakeTimeout   string   `json:"wake_timeout,omitempty"`
	StopMethod    string   `json:"stop_method,omitempty"`
	StopTimeout   string   `json:"stop_timeout,omitempty"` // stop_method = "stop" only
	StopSignal    string   `json:"stop_signal,omitempty"`  // stop_method = "stop" | "kill" only
	StartEndpoint string   `json:"start_endpoint,omitempty"`
	Running       bool     `json:"running"`
	// contains filtered or unexported fields
}

func FromDocker

func FromDocker(c *types.Container, dockerHost string) (res *Container)

func FromJSON

func FromJSON(json types.ContainerJSON, dockerHost string) *Container

func Inspect

func Inspect(dockerHost string, containerID string) (*Container, error)

type LabelMap

type LabelMap = map[string]any

func ParseLabels

func ParseLabels(labels map[string]string) (LabelMap, E.Error)

type PortMapping

type PortMapping = map[int]types.Port

type SharedClient

type SharedClient struct {
	*client.Client
	// contains filtered or unexported fields
}

func ConnectClient

func ConnectClient(host string) (*SharedClient, error)

ConnectClient creates a new Docker client connection to the specified host.

Returns existing client if available.

Parameters:

  • host: the host to connect to (either a URL or common.DockerHostFromEnv).

Returns:

  • Client: the Docker client connection.
  • error: an error if the connection failed.

func (*SharedClient) Close

func (c *SharedClient) Close()

if the client is still referenced, this is no-op.

func (*SharedClient) Inspect

func (c *SharedClient) Inspect(containerID string) (*Container, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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