Documentation
¶
Overview ¶
Package docker Date: 2024/6/27 18:47 Author: Amu Description:
Package docker Date: 2023/4/19 14:19 Author: Amu Description: docker 容器操作
Package docker Date: 2023/4/19 15:29 Author: Amu Description:
Package docker Date: 2023/4/19 15:24 Author: Amu Description:
Package docker Date: 2023/4/19 14:19 Author: Amu Description: docker 网络操作
Package docker Date: 2024/5/10 16:38 Author: Amu Description:
Index ¶
- Constants
- type ContainerSummary
- type Image
- type Manager
- func (m *Manager) ContainerLogs(ctx context.Context, containerID string) (io.ReadCloser, error)
- func (m *Manager) CopyFileToContainer(ctx context.Context, containerID, srcFile, dstFile string) error
- func (m *Manager) CreateContainer(ctx context.Context, imageName string, networkID string, networkMode string, ...) (string, error)
- func (m *Manager) CreateNetwork(ctx context.Context, name string, driver string, networkSegment string, ...) (string, error)
- func (m *Manager) DeleteContainer(ctx context.Context, containerID string) error
- func (m *Manager) DeleteNetwork(ctx context.Context, networkID string) error
- func (m *Manager) ExportImage(ctx context.Context, imageIDs []string, targetFile string) error
- func (m *Manager) GetContainerByName(ctx context.Context, name string) (ContainerSummary, error)
- func (m *Manager) GetContainerCPU(ctx context.Context, containerID string) (float64, error)
- func (m *Manager) GetContainerIDByName(ctx context.Context, name string) (string, error)
- func (m *Manager) GetContainerMem(ctx context.Context, containerID string) (float64, float64, float64, error)
- func (m *Manager) GetImageByID(ctx context.Context, imageID string) (*Image, error)
- func (m *Manager) GetImageByName(ctx context.Context, imageName string) (*Image, error)
- func (m *Manager) ImportImage(ctx context.Context, sourceFile string) error
- func (m *Manager) JoinNetwork(ctx context.Context, containerID string, networkID string) error
- func (m *Manager) LeaveNetwork(ctx context.Context, containerID string, networkID string) error
- func (m *Manager) ListContainer(ctx context.Context) ([]ContainerSummary, error)
- func (m *Manager) ListImage(ctx context.Context) ([]Image, error)
- func (m *Manager) ListNetwork(ctx context.Context) ([]Network, error)
- func (m *Manager) PruneImages(ctx context.Context) error
- func (m *Manager) PruneNetwork(ctx context.Context) error
- func (m *Manager) PullImage(ctx context.Context, term string) error
- func (m *Manager) QueryNetwork(ctx context.Context, networkID string) (*Network, error)
- func (m *Manager) RemoveImage(ctx context.Context, imageID string) error
- func (m *Manager) RenameContainer(ctx context.Context, containerID, newName string) error
- func (m *Manager) RestartContainer(ctx context.Context, containerID string) error
- func (m *Manager) SearchImage(ctx context.Context, term string) ([]registry.SearchResult, error)
- func (m *Manager) StartContainer(ctx context.Context, containerID string) error
- func (m *Manager) StopContainer(ctx context.Context, containerID string) error
- func (m *Manager) TagImage(ctx context.Context, oldTag string, newTag string) error
- func (m *Manager) Version(ctx context.Context) (*Version, error)
- type Network
- type PortMapping
- type SubNetworkConfig
- type Version
Constants ¶
const (
AmprobeLabel = "amprobe.manual"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerSummary ¶
type ContainerSummary struct { ID string `json:"id"` // ID Name string `json:"name"` // Name Image string `json:"image"` // Image State string `json:"state"` // State: created running paused restarting removing exited dead Created string `json:"created"` // create time Uptime string `json:"uptime"` // uptime in seconds IP string `json:"ip"` // ip Labels map[string]string `json:"labels"` }
type Manager ¶
func NewManager ¶
func (*Manager) ContainerLogs ¶
func (*Manager) CopyFileToContainer ¶
func (m *Manager) CopyFileToContainer(ctx context.Context, containerID, srcFile, dstFile string) error
CopyFileToContainer 向容器中拷贝文件
func (*Manager) CreateContainer ¶
func (m *Manager) CreateContainer(ctx context.Context, imageName string, networkID string, networkMode string, networkName string, containerName string, ports []string, vols []string, labels map[string]string) (string, error)
CreateContainer 根据条件创建容器(各种条件会比较复杂),创建成功后返回 containerID,此时容器状态为 created
func (*Manager) CreateNetwork ¶
func (m *Manager) CreateNetwork(ctx context.Context, name string, driver string, networkSegment string, labels map[string]string) (string, error)
CreateNetwork creates a new network.
func (*Manager) DeleteContainer ¶
DeleteContainer 删除指定容器
func (*Manager) DeleteNetwork ¶
DeleteNetwork removes a network by network id.
func (*Manager) ExportImage ¶
ExportImage 镜像导出
func (*Manager) GetContainerByName ¶
GetContainerByName 根据名称获取指定 container
func (*Manager) GetContainerCPU ¶
GetContainerCPU 获取指定容器 CPU 使用情况,单位百分比
func (*Manager) GetContainerIDByName ¶
GetContainerIDByName 根据名称获取指定 container ID
func (*Manager) GetContainerMem ¶
func (m *Manager) GetContainerMem(ctx context.Context, containerID string) (float64, float64, float64, error)
GetContainerMem 获取指定容器的内存使用情况,单位 MB
func (*Manager) GetImageByID ¶
GetImageByID 根据 imageID 获取 Image 详情
func (*Manager) GetImageByName ¶
GetImageByName 根据 imageName 获取 Image 详情, imageName -> image:latest
func (*Manager) ImportImage ¶
ImportImage 镜像导入
func (*Manager) JoinNetwork ¶
func (*Manager) LeaveNetwork ¶
func (*Manager) ListContainer ¶
func (m *Manager) ListContainer(ctx context.Context) ([]ContainerSummary, error)
ListContainer 获取所有容器 []ContainerSummary
func (*Manager) ListNetwork ¶
ListNetwork lists all networks.
func (*Manager) PruneNetwork ¶
PruneNetwork removes all dangling networks.
func (*Manager) PullImage ¶
PullImage 根据名称拉去镜像,term 可以是 镜像名称(ubuntu 会拉去 ubuntu:latest) 也可以是 镜像名称:tag(ubuntu:18.04)
func (*Manager) QueryNetwork ¶
QueryNetwork queries a network by its ID.
func (*Manager) RemoveImage ¶
func (*Manager) RenameContainer ¶
func (*Manager) RestartContainer ¶
RestartContainer 重启指定容器
func (*Manager) SearchImage ¶
SearchImage 通过关键词查找镜像
func (*Manager) StartContainer ¶
StartContainer 根据 containerID 启动容器
func (*Manager) StopContainer ¶
StopContainer stop 指定容器