dockerclient

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEndpoint is returned when the endpoint is not a valid URL.
	ErrInvalidEndpoint = errors.New("invalid endpoint")
	// ErrConnectionRefused is returned when the client cannot connect to the given endpoint.
	ErrConnectionRefused = errors.New("cannot connect to Docker endpoint")
)
View Source
var ErrNoSuchImage = errors.New("no such image")

ErrNoSuchImage is error returned when the image does not exist.

Functions

This section is empty.

Types

type APIContainers added in v0.3.23

type APIContainers struct {
	ID         string            `json:"Id"`
	Image      string            `json:"Image,omitempty"`
	State      string            `json:"State,omitempty"`
	Status     string            `json:"Status,omitempty"`
	Command    string            `json:"Command,omitempty"`
	SizeRw     int64             `json:"SizeRw,omitempty"`
	SizeRootFs int64             `json:"SizeRootFs,omitempty"`
	Names      []string          `json:"Names,omitempty"`
	Ports      []APIPort         `json:"Ports,omitempty"`
	Mounts     []APIMount        `json:"Mounts,omitempty"`
	Labels     map[string]string `json:"Labels,omitempty"`
	Networks   NetworkList       `json:"NetworkSettings,omitempty"`
}

APIContainers Docker API ListContainers 响应体切片中的容器实体

type APIImages added in v0.3.20

type APIImages struct {
	ID          string            `json:"Id"`
	RepoTags    []string          `json:"RepoTags,omitempty"`
	Created     int64             `json:"Created,omitempty"`
	Size        int64             `json:"Size,omitempty"`
	VirtualSize int64             `json:"VirtualSize,omitempty"`
	ParentID    string            `json:"ParentId,omitempty"`
	RepoDigests []string          `json:"RepoDigests,omitempty"`
	Labels      map[string]string `json:"Labels,omitempty"`
}

APIImages represent an image returned to the ListImages call.

type APIMount added in v0.3.23

type APIMount struct {
	Name        string `json:"Name,omitempty"`
	Mode        string `json:"Mode,omitempty"`
	Source      string `json:"Source,omitempty"`
	Driver      string `json:"Driver,omitempty"`
	Destination string `json:"Destination,omitempty"`
	Propagation string `json:"Propagation,omitempty"`
}

APIMount 容器的挂载点

type APIPort added in v0.3.23

type APIPort struct {
	Type        string `json:"Type,omitempty"`
	PublicPort  int64  `json:"publicPort,omitempty"`
	PrivatePort int64  `json:"privatePort,omitempty"`
}

APIPort Docker API 返回的端口映射类型

type Client added in v0.3.16

type Client struct {
	Dialer     Dialer
	TLSConfig  *tls.Config
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient added in v0.3.16

func NewClient() (*Client, error)

NewClient returns a Client

func NewTLSClient

func NewTLSClient(endpoint string, dockerCertPath string) (*Client, error)

NewTLSClient returns a Client instance ready for TLS communications with the givens server endpoint, key and certificates, using a specific remote API version. TODO: 🚧 Under construction...

func (*Client) InspectService added in v0.3.27

func (c *Client) InspectService(id string) (*swarm.Service, error)

InspectService returns information about a service by its ID.

More: https://docs.docker.com/engine/api/v1.41/#tag/Service/operation/ServiceInspect

func (*Client) ListContainers added in v0.3.23

func (c *Client) ListContainers() ([]APIContainers, error)

ListContainers 返回容器切片

More: https://docs.docker.com/engine/api/v1.41/#tag/Container

func (*Client) ListImages added in v0.3.20

func (c *Client) ListImages() ([]APIImages, error)

ListImages returns the list of available images in the server.

More: https://docs.docker.com/engine/api/v1.23/#list-images

func (*Client) ListServices added in v0.3.18

func (c *Client) ListServices() ([]swarm.Service, error)

ListServices returns a slices of services

More: https://docs.docker.com/engine/api/v1.41/#tag/Service/operation/ServiceList

func (*Client) RemoveContainer added in v0.3.25

func (c *Client) RemoveContainer(opts RemoveContainerOptions) error

RemoveContainer 删除容器

More: https://docs.docker.com/engine/api/v1.25/#tag/Container/operation/ContainerDelete

func (*Client) RemoveImage added in v0.3.20

func (c *Client) RemoveImage(name string) error

RemoveImage remove an image by its name or ID.

More: https://docs.docker.com/engine/api/v1.41/#tag/Image/operation/ImageDelete.

func (*Client) StopContainer added in v0.3.25

func (c *Client) StopContainer(id string) error

StopContainer 停止容器

func (*Client) UpdateService added in v0.3.27

func (c *Client) UpdateService(id string, opts UpdateServiceOptions) error

type ContainerNetwork added in v0.3.23

type ContainerNetwork struct {
	Aliases             []string `json:"Aliases,omitempty"`
	IPPrefixLen         int      `json:"IPPrefixLen,omitempty"`
	GlobalIPv6PrefixLen int      `json:"GlobalIPv6PrefixLen,omitempty"`
	Gateway             string   `json:"Gateway,omitempty"`
	NetworkID           string   `json:"NetworkID,omitempty"`
	IPAddress           string   `json:"IPAddress,omitempty"`
	EndpointID          string   `json:"EndpointID,omitempty"`
	MacAddress          string   `json:"MacAddress,omitempty"`
	IPv6Gateway         string   `json:"IPv6Gateway,omitempty"`
	GlobalIPv6Address   string   `json:"GlobalIPv6Address,omitempty"`
}

ContainerNetwork 容器的网络

type ContainerNotFound added in v0.3.25

type ContainerNotFound struct {
	ID  string
	Err error
}

ContainerNotFound 容器没找到

func (*ContainerNotFound) Error added in v0.3.25

func (err *ContainerNotFound) Error() string

type ContainerNotRunning added in v0.3.25

type ContainerNotRunning struct {
	ID string
}

ContainerNotRunning 容器未运行

func (*ContainerNotRunning) Error added in v0.3.25

func (err *ContainerNotRunning) Error() string

type Dialer added in v0.3.18

type Dialer interface {
	Dial(network, address string) (net.Conn, error)
}

type Error added in v0.3.20

type Error struct {
	Status  int
	Message string
}

Error represents failures in the API.

func (*Error) Error added in v0.3.20

func (e *Error) Error() string

type NetworkList added in v0.3.23

type NetworkList struct {
	Networks map[string]ContainerNetwork `json:"Networks,omitempty"`
}

NetworkList 容器的网络映射

type NoSuchService added in v0.3.27

type NoSuchService struct {
	ID  string
	Err error
}

func (*NoSuchService) Error added in v0.3.27

func (err *NoSuchService) Error() string

type RemoveContainerOptions added in v0.3.25

type RemoveContainerOptions struct {
	// 容器ID
	ID string
}

RemoveContainerOptions 封装用于删除容器的选项

type UpdateServiceOptions added in v0.3.27

type UpdateServiceOptions struct {
	Version uint64
	swarm.ServiceSpec
}

Jump to

Keyboard shortcuts

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