[go: up one dir, main page]

network

package
v1.52.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 8 Imported by: 35

Documentation

Index

Constants

View Source
const (
	// NetworkDefault is a platform-independent alias to choose the platform-specific default network stack.
	NetworkDefault = "default"
	// NetworkHost is the name of the predefined network used when the NetworkMode host is selected (only available on Linux)
	NetworkHost = "host"
	// NetworkNone is the name of the predefined network used when the NetworkMode none is selected (available on both Linux and Windows)
	NetworkNone = "none"
	// NetworkBridge is the name of the default network on Linux
	NetworkBridge = "bridge"
	// NetworkNat is the name of the default network on Windows
	NetworkNat = "nat"
)

Variables

This section is empty.

Functions

func ValidateIPAM

func ValidateIPAM(ipam *IPAM, enableIPv6 bool) error

ValidateIPAM checks whether the network's IPAM passed as argument is valid. It returns a joinError of the list of errors found.

Types

type Address

type Address struct {
	Addr      string
	PrefixLen int
}

Address represents an IP address

type ConfigReference

type ConfigReference struct {

	// The name of the config-only network that provides the network's
	// configuration. The specified network must be an existing config-only
	// network. Only network names are allowed, not network IDs.
	//
	// Example: config_only_network_01
	Network string `json:"Network"`
}

ConfigReference The config-only network source to provide the configuration for this network.

swagger:model ConfigReference

type CreateRequest

type CreateRequest struct {
	Name       string            // Name is the requested name of the network.
	Driver     string            // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
	Scope      string            // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
	EnableIPv4 *bool             `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
	EnableIPv6 *bool             `json:",omitempty"` // EnableIPv6 represents whether to enable IPv6.
	IPAM       *IPAM             // IPAM is the network's IP Address Management.
	Internal   bool              // Internal represents if the network is used internal only.
	Attachable bool              // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
	Ingress    bool              // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
	ConfigOnly bool              // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
	ConfigFrom *ConfigReference  // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
	Options    map[string]string // Options specifies the network-specific options to use for when creating the network.
	Labels     map[string]string // Labels holds metadata specific to the network being created.

	// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
	// package to older daemons.
	CheckDuplicate *bool `json:",omitempty"`
}

CreateRequest is the request message sent to the server for network create call.

type CreateResponse

type CreateResponse struct {

	// The ID of the created network.
	// Example: b5c4fc71e8022147cd25de22b22173de4e3b170134117172eb595cb91b4e7e5d
	// Required: true
	ID string `json:"Id"`

	// Warnings encountered when creating the container
	// Required: true
	Warning string `json:"Warning"`
}

CreateResponse NetworkCreateResponse

OK response to NetworkCreate operation

swagger:model CreateResponse

type EndpointIPAMConfig

type EndpointIPAMConfig struct {
	IPv4Address  string   `json:",omitempty"`
	IPv6Address  string   `json:",omitempty"`
	LinkLocalIPs []string `json:",omitempty"`
}

EndpointIPAMConfig represents IPAM configurations for the endpoint

func (*EndpointIPAMConfig) Copy

Copy makes a copy of the endpoint ipam config

func (*EndpointIPAMConfig) IsInRange

func (cfg *EndpointIPAMConfig) IsInRange(v4Subnets []NetworkSubnet, v6Subnets []NetworkSubnet) error

IsInRange checks whether static IP addresses are valid in a specific network.

func (*EndpointIPAMConfig) Validate

func (cfg *EndpointIPAMConfig) Validate() error

Validate checks whether cfg is valid.

type EndpointResource

type EndpointResource struct {

	// name
	// Example: container_1
	Name string `json:"Name"`

	// endpoint ID
	// Example: 628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a
	EndpointID string `json:"EndpointID"`

	// mac address
	// Example: 02:42:ac:13:00:02
	MacAddress string `json:"MacAddress"`

	// IPv4 address
	// Example: 172.19.0.2/16
	IPv4Address string `json:"IPv4Address"`

	// IPv6 address
	IPv6Address string `json:"IPv6Address"`
}

EndpointResource contains network resources allocated and used for a container in a network.

swagger:model EndpointResource

type EndpointSettings

type EndpointSettings struct {
	// Configurations
	IPAMConfig *EndpointIPAMConfig
	Links      []string
	Aliases    []string // Aliases holds the list of extra, user-specified DNS names for this endpoint.
	// MacAddress may be used to specify a MAC address when the container is created.
	// Once the container is running, it becomes operational data (it may contain a
	// generated address).
	MacAddress string
	DriverOpts map[string]string

	// GwPriority determines which endpoint will provide the default gateway
	// for the container. The endpoint with the highest priority will be used.
	// If multiple endpoints have the same priority, they are lexicographically
	// sorted based on their network name, and the one that sorts first is picked.
	GwPriority int
	// Operational data
	NetworkID           string
	EndpointID          string
	Gateway             string
	IPAddress           string
	IPPrefixLen         int
	IPv6Gateway         string
	GlobalIPv6Address   string
	GlobalIPv6PrefixLen int
	// DNSNames holds all the (non fully qualified) DNS names associated to this endpoint. First entry is used to
	// generate PTR records.
	DNSNames []string
}

EndpointSettings stores the network endpoint details

func (*EndpointSettings) Copy

func (es *EndpointSettings) Copy() *EndpointSettings

Copy makes a deep copy of `EndpointSettings`

type IPAM

type IPAM struct {
	Driver  string
	Options map[string]string // Per network IPAM driver options
	Config  []IPAMConfig
}

IPAM represents IP Address Management

type IPAMConfig

type IPAMConfig struct {
	Subnet     string            `json:",omitempty"`
	IPRange    string            `json:",omitempty"`
	Gateway    string            `json:",omitempty"`
	AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"`
}

IPAMConfig represents IPAM configurations

type Inspect

type Inspect struct {
	Network

	// Contains endpoints attached to the network.
	//
	// Example: {"19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c":{"EndpointID":"628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a","IPv4Address":"172.19.0.2/16","IPv6Address":"","MacAddress":"02:42:ac:13:00:02","Name":"test"}}
	Containers map[string]EndpointResource `json:"Containers"`

	// List of services using the network. This field is only present for
	// swarm scope networks, and omitted for local scope networks.
	//
	Services map[string]ServiceInfo `json:"Services,omitempty"`
}

Inspect The body of the "get network" http response message.

swagger:model Inspect

type Network

type Network struct {

	// Name of the network.
	//
	// Example: my_network
	Name string `json:"Name"`

	// ID that uniquely identifies a network on a single machine.
	//
	// Example: 7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99
	ID string `json:"Id"`

	// Date and time at which the network was created in
	// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds.
	//
	// Example: 2016-10-19T04:33:30.360899459Z
	Created timeext.Time `json:"Created"`

	// The level at which the network exists (e.g. `swarm` for cluster-wide
	// or `local` for machine level)
	//
	// Example: local
	Scope string `json:"Scope"`

	// The name of the driver used to create the network (e.g. `bridge`,
	// `overlay`).
	//
	// Example: overlay
	Driver string `json:"Driver"`

	// Whether the network was created with IPv4 enabled.
	//
	// Example: true
	EnableIPv4 bool `json:"EnableIPv4"`

	// Whether the network was created with IPv6 enabled.
	//
	// Example: false
	EnableIPv6 bool `json:"EnableIPv6"`

	// The network's IP Address Management.
	//
	IPAM IPAM `json:"IPAM"`

	// Whether the network is created to only allow internal networking
	// connectivity.
	//
	// Example: false
	Internal bool `json:"Internal"`

	// Whether a global / swarm scope network is manually attachable by regular
	// containers from workers in swarm mode.
	//
	// Example: false
	Attachable bool `json:"Attachable"`

	// Whether the network is providing the routing-mesh for the swarm cluster.
	//
	// Example: false
	Ingress bool `json:"Ingress"`

	// config from
	ConfigFrom ConfigReference `json:"ConfigFrom"`

	// Whether the network is a config-only network. Config-only networks are
	// placeholder networks for network configurations to be used by other
	// networks. Config-only networks cannot be used directly to run containers
	// or services.
	//
	ConfigOnly bool `json:"ConfigOnly"`

	// Network-specific options uses when creating the network.
	//
	// Example: {"com.docker.network.bridge.default_bridge":"true","com.docker.network.bridge.enable_icc":"true","com.docker.network.bridge.enable_ip_masquerade":"true","com.docker.network.bridge.host_binding_ipv4":"0.0.0.0","com.docker.network.bridge.name":"docker0","com.docker.network.driver.mtu":"1500"}
	Options map[string]string `json:"Options"`

	// Metadata specific to the network being created.
	//
	// Example: {"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"}
	Labels map[string]string `json:"Labels"`

	// List of peer nodes for an overlay network. This field is only present
	// for overlay networks, and omitted for other network types.
	//
	Peers []PeerInfo `json:"Peers,omitempty"`
}

Network network

swagger:model Network

type NetworkSubnet

type NetworkSubnet interface {
	// Contains checks whether the NetworkSubnet contains [addr].
	Contains(addr net.IP) bool
	// IsStatic checks whether the subnet was statically allocated (ie. user-defined).
	IsStatic() bool
}

NetworkSubnet describes a user-defined subnet for a specific network. It's only used to validate if an EndpointIPAMConfig is valid for a specific network.

type NetworkingConfig

type NetworkingConfig struct {
	EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
}

NetworkingConfig represents the container's networking configuration for each of its interfaces Carries the networking configs specified in the `docker run` and `docker network connect` commands

type PeerInfo

type PeerInfo struct {

	// ID of the peer-node in the Swarm cluster.
	// Example: 6869d7c1732b
	Name string `json:"Name"`

	// IP-address of the peer-node in the Swarm cluster.
	// Example: 10.133.77.91
	IP string `json:"IP"`
}

PeerInfo represents one peer of an overlay network.

swagger:model PeerInfo

type PruneReport

type PruneReport struct {
	NetworksDeleted []string
}

PruneReport contains the response for Engine API: POST "/networks/prune"

type ServiceInfo

type ServiceInfo struct {
	VIP          string
	Ports        []string
	LocalLBIndex int
	Tasks        []Task
}

ServiceInfo represents service parameters with the list of service's tasks

type Summary

type Summary struct {
	Network
}

Summary Network list response item

swagger:model Summary

type Task

type Task struct {

	// name
	Name string `json:"Name"`

	// endpoint ID
	EndpointID string `json:"EndpointID"`

	// endpoint IP
	EndpointIP string `json:"EndpointIP"`

	// info
	Info map[string]string `json:"Info"`
}

Task carries the information about one backend task

swagger:model Task

Jump to

Keyboard shortcuts

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