Documentation
¶
Overview ¶
Package docker 实现 Docker 管理模块:查看容器、启停、日志,以及检查镜像更新并按原配置重建容器。
直接调用 Docker Engine API(默认 /var/run/docker.sock),不依赖官方 SDK。
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) Action(ctx context.Context, id, action string) error
- func (c *Client) ConnectNetwork(ctx context.Context, network, id string, endpoint map[string]any) error
- func (c *Client) Containers(ctx context.Context) ([]Container, error)
- func (c *Client) Create(ctx context.Context, name string, body any) (string, error)
- func (c *Client) ImageID(ctx context.Context, ref string) (string, error)
- func (c *Client) Inspect(ctx context.Context, id string) (map[string]json.RawMessage, error)
- func (c *Client) Logs(ctx context.Context, id string, tail int) (string, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Pull(ctx context.Context, ref string) error
- func (c *Client) Remove(ctx context.Context, id string) error
- func (c *Client) Rename(ctx context.Context, id, name string) error
- type Container
- type ContainerView
- type Module
- type Settings
- type UpdateInfo
Constants ¶
const ID = "docker"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是精简的 Docker Engine API 客户端。
func (*Client) ConnectNetwork ¶
func (c *Client) ConnectNetwork(ctx context.Context, network, id string, endpoint map[string]any) error
ConnectNetwork 把容器连接到网络。
func (*Client) Containers ¶
Containers 列出全部容器。
type Container ¶
type Container struct {
ID string `json:"Id"`
Names []string `json:"Names"`
Image string `json:"Image"`
ImageID string `json:"ImageID"`
State string `json:"State"`
Status string `json:"Status"`
Created int64 `json:"Created"`
Labels map[string]string `json:"Labels"`
Ports []struct {
IP string `json:"IP"`
PrivatePort int `json:"PrivatePort"`
PublicPort int `json:"PublicPort"`
Type string `json:"Type"`
} `json:"Ports"`
}
Container 是容器列表项。
type ContainerView ¶
type ContainerView struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
State string `json:"state"`
Status string `json:"status"`
Created int64 `json:"created"`
Ports []string `json:"ports"`
Project string `json:"project,omitempty"`
Update *UpdateInfo `json:"update,omitempty"`
Busy bool `json:"busy"`
Labels map[string]string `json:"-"`
}
ContainerView 是界面展示的容器信息。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是 Docker 管理模块。