docker

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSocket

func CheckSocket(socketPath string) bool

CheckSocket checks if Docker socket is available

func IsWithinHostNetwork

func IsWithinHostNetwork(socketPath string, targetAddress string, targetPort int) (bool, error)

IsWithinHostNetwork checks if a provided target is within the host container network

Types

type Container

type Container struct {
	ID       string             `json:"id"`
	Name     string             `json:"name"`
	Image    string             `json:"image"`
	State    string             `json:"state"`
	Status   string             `json:"status"`
	Ports    []Port             `json:"ports"`
	Labels   map[string]string  `json:"labels"`
	Created  int64              `json:"created"`
	Networks map[string]Network `json:"networks"`
	Hostname string             `json:"hostname"` // added to use hostname if available instead of network address

}

Container represents a Docker container

func ListContainers

func ListContainers(socketPath string, enforceNetworkValidation bool) ([]Container, error)

ListContainers lists all Docker containers with their network information

type EventCallback

type EventCallback func(containers []Container)

EventCallback defines the function signature for handling Docker events

type EventMonitor

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

EventMonitor handles Docker event monitoring

func NewEventMonitor

func NewEventMonitor(socketPath string, enforceNetworkValidation bool, callback EventCallback) (*EventMonitor, error)

NewEventMonitor creates a new Docker event monitor

func (*EventMonitor) Start

func (em *EventMonitor) Start() error

Start begins monitoring Docker events

func (*EventMonitor) Stop

func (em *EventMonitor) Stop()

Stop stops the event monitoring

type Network

type Network struct {
	NetworkID           string   `json:"networkId"`
	EndpointID          string   `json:"endpointId"`
	Gateway             string   `json:"gateway,omitempty"`
	IPAddress           string   `json:"ipAddress,omitempty"`
	IPPrefixLen         int      `json:"ipPrefixLen,omitempty"`
	IPv6Gateway         string   `json:"ipv6Gateway,omitempty"`
	GlobalIPv6Address   string   `json:"globalIPv6Address,omitempty"`
	GlobalIPv6PrefixLen int      `json:"globalIPv6PrefixLen,omitempty"`
	MacAddress          string   `json:"macAddress,omitempty"`
	Aliases             []string `json:"aliases,omitempty"`
	DNSNames            []string `json:"dnsNames,omitempty"`
}

Network represents network information for a Docker container

type Port

type Port struct {
	PrivatePort int    `json:"privatePort"`
	PublicPort  int    `json:"publicPort,omitempty"`
	Type        string `json:"type"`
	IP          string `json:"ip,omitempty"`
}

Port represents a port mapping for a Docker container

Jump to

Keyboard shortcuts

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