docker

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package docker 提供与本机 Docker 守护进程交互的功能;包括镜像管理,容器启动

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	DockerClient *client.Client
}

func GetClient

func GetClient() *Client

func (*Client) BuildFromPath

func (c *Client) BuildFromPath(path, tag string) (imageID string, err error)

func (*Client) BuildFromTar

func (c *Client) BuildFromTar(tar io.Reader, tag string) (imageID string, err error)

func (*Client) ContainerIsRunningByImage

func (c *Client) ContainerIsRunningByImage(image string) (isRunning bool, err error)

ContainerIsRunningByImage 返回是否有镜像对应的容器在运行

func (*Client) ContainerKillByImage added in v1.9.1

func (c *Client) ContainerKillByImage(image string, signal string) (err error)

ContainerKillByImage 给容器发送信号

func (*Client) ContainerList added in v1.9.1

func (c *Client) ContainerList() ([]types.Container, error)

ContainerList 返回启动的容器列表

func (*Client) ContainerRestartByImage

func (c *Client) ContainerRestartByImage(image string) (err error)

ContainerRestartByImage 重启容器

func (*Client) ContainerRun added in v1.5.0

func (c *Client) ContainerRun(image string, conf container.Config, hostConf container.HostConfig) (containerID string, err error)

ContainerRun 根据镜像创建容器并运行

func (*Client) GetContainerByImage

func (c *Client) GetContainerByImage(image string) (id string, err error)

func (*Client) GetImageNewestTag added in v1.5.0

func (c *Client) GetImageNewestTag(img Image) (tag string, err error)

func (*Client) ImageLoad

func (c *Client) ImageLoad(target string) (err error)

ImageLoad load docker image(s) from a tar file.

func (*Client) ImageRemove

func (c *Client) ImageRemove(refStr string) (err error)

ImageRemove 删除镜像

func (*Client) ImageSave

func (c *Client) ImageSave(target string, imgs ...string) (err error)

ImageSave save docker images to tar file.

func (*Client) Inspect

func (c *Client) Inspect(imageID string) (inspect types.ImageInspect, err error)

func (*Client) IsImageAdd

func (c *Client) IsImageAdd(refStr string) (isAdded bool)

IsImageAdd 镜像是否已经拉取到本地

func (*Client) IsImageNewest

func (c *Client) IsImageNewest() (isNewest bool, err error)

IsImageNewest TODO 镜像是否最新

func (*Client) Pull

func (c *Client) Pull(refStr string) (err error)

Pull 拉取镜像

func (*Client) RemoveContainer added in v1.9.1

func (c *Client) RemoveContainer(image string) (err error)

RemoveContainer 删除容器 TODO 优化

func (*Client) StopContainer added in v1.9.1

func (c *Client) StopContainer(image string) (err error)

StopContainer 停止容器 TODO 优化

type ErrorDetail

type ErrorDetail struct {
	Message string `json:"message"`
}

type Image

type Image struct {
	Name     string `json:"name" yaml:"name"`
	Tag      string `json:"tag" yaml:"tag"`           // 镜像标签
	Registry string `json:"registry" yaml:"registry"` // 仓库地址
}

Image 镜像

func (Image) RefStr

func (i Image) RefStr() string

func (Image) Repository

func (i Image) Repository() string

type LineResult

type LineResult struct {
	Stream string `json:"stream"`
	AUX    struct {
		ID string `json:"id"`
	} `json:"aux"`
	Error       string      `json:"error"`
	ErrorDetail ErrorDetail `json:"errorDetail"`
}

Jump to

Keyboard shortcuts

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