docker

package
v0.0.0-...-65ae77c Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MulanPSL-2.0 Imports: 11 Imported by: 0

README

docker

Docker连接管理,包含本地连接和远程连接。

注意事项:

  • github.com/docker/docker:版本v23.0.1+incompatible

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Ctx context.Context   // 网络请求上下文
	Cli *dockerCli.Client // docker库的连接
}

Docker连接

func NewClient

func NewClient(ctx context.Context) *Client

新建Docker连接

func (*Client) CheckCli

func (c *Client) CheckCli() error

检查连接

func (*Client) Close

func (c *Client) Close()

断开操作

func (*Client) Connect

func (c *Client) Connect(host string) (err error)

连接操作 host有值(例如"http://127.0.0.1:1234"),则连接到远程docker上 host为空,则连接到/var/run/docker.sock上

func (*Client) ContainerCreate

func (c *Client) ContainerCreate(
	containerName string,
	config *container.Config,
	hostConfig *container.HostConfig,
	networkingConfig *network.NetworkingConfig,
	platformConfig *specs.Platform,
) (rsp container.CreateResponse, err error)

创建容器

func (*Client) ContainerInspect

func (c *Client) ContainerInspect(
	containerId string,
) (rsp types.ContainerJSON, err error)

获取容器信息

func (*Client) ContainerList

func (c *Client) ContainerList(
	options types.ContainerListOptions,
) (list []types.Container, err error)

获取所有容器信息

func (*Client) ContainerLogs

func (c *Client) ContainerLogs(
	containerId string,
	options types.ContainerLogsOptions,
) (out string, err error)

查看容器日志

func (*Client) ContainerRemove

func (c *Client) ContainerRemove(
	containerId string,
	options types.ContainerRemoveOptions,
) (err error)

移除容器

func (*Client) ContainerStart

func (c *Client) ContainerStart(
	containerId string,
	options types.ContainerStartOptions,
) (err error)

启动容器

func (*Client) ContainerStop

func (c *Client) ContainerStop(
	containerId string,
	options container.StopOptions,
) (err error)

停止容器

func (*Client) GenerateUserPwdAuth

func (c *Client) GenerateUserPwdAuth(
	username string,
	password string,
) string

简易的用户名+密码鉴权信息

func (*Client) ImageInspect

func (c *Client) ImageInspect(
	image string,
) (info types.ImageInspect, err error)

获取镜像信息

func (*Client) ImageList

func (c *Client) ImageList(
	options types.ImageListOptions,
) (list []types.ImageSummary, err error)

获取镜像列表

func (*Client) ImagePull

func (c *Client) ImagePull(
	image string,
	options types.ImagePullOptions,
) (out string, err error)

拉取镜像,可以使用GenerateUserPwdAuth生成用户名密码鉴权信息

Jump to

Keyboard shortcuts

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