docker

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoTask added in v0.1.5

type AutoTask struct {
	// contains filtered or unexported fields
}

AutoTask 结构体封装了创建 Docker 容器的通用操作

func NewAutoTask added in v0.1.5

func NewAutoTask(opt Option, ops ...client.Opt) *AutoTask

NewAutoTask 创建一个 AutoTask 结构体的实例

func (*AutoTask) ContainerExists added in v0.1.5

func (at *AutoTask) ContainerExists(callBack func())

ContainerExists 检测是否存在指定容器名称

func (*AutoTask) Delete added in v0.1.7

func (at *AutoTask) Delete(cname string) (err error)

func (*AutoTask) DeleteCreatedContainer added in v1.2.0

func (at *AutoTask) DeleteCreatedContainer()

func (*AutoTask) EchoError added in v0.1.5

func (at *AutoTask) EchoError(name string, err error, flag bool)

func (*AutoTask) PullImage added in v0.1.7

func (at *AutoTask) PullImage(imgName string) error

PullImage 拉取容器

func (*AutoTask) Run added in v0.1.5

func (at *AutoTask) Run()

Run 创建并运行 Docker 容器

func (*AutoTask) Start added in v0.1.7

func (at *AutoTask) Start(cname string) (err error)

func (*AutoTask) Stop added in v0.1.7

func (at *AutoTask) Stop() (err error)

func (*AutoTask) WithCommand added in v0.1.7

func (at *AutoTask) WithCommand(Command []string) *AutoTask

func (*AutoTask) WithContainerName added in v0.1.5

func (at *AutoTask) WithContainerName(containerName string) *AutoTask

WithContainerName 设置容器名称

func (*AutoTask) WithEnv added in v0.1.5

func (at *AutoTask) WithEnv(env []string) *AutoTask

WithEnv 设置容器环境变量

func (*AutoTask) WithImage added in v0.1.5

func (at *AutoTask) WithImage(image string) *AutoTask

WithImage 设置 Docker 镜像名称

func (*AutoTask) WithNetwork added in v0.1.5

func (at *AutoTask) WithNetwork(networkName string) *AutoTask

WithNetwork 设置自定义网络的名称

func (*AutoTask) WithPortMappings added in v0.1.5

func (at *AutoTask) WithPortMappings(portMappings map[string]string) *AutoTask

WithPortMappings 设置端口映射配置

func (*AutoTask) WithStaticIp added in v0.1.5

func (at *AutoTask) WithStaticIp(IPAddress string) *AutoTask

WithStaticIp 设置容器静态IP

func (*AutoTask) WithSubnet added in v0.1.5

func (at *AutoTask) WithSubnet(subnet, gateway string) *AutoTask

WithSubnet 设置子网配置

func (*AutoTask) WithVolumeMappings added in v0.1.5

func (at *AutoTask) WithVolumeMappings(volumeMappings []VolumeMapping) *AutoTask

添加 WithVolumeMappings 方法用于设置数据卷映射

type Option added in v0.1.5

type Option struct {
	NetworkName    string            // 自定义网络的名称
	IPAddress      string            // 指定IP地址
	Subnet         string            // 子网配置
	Gateway        string            // 网关配置
	Image          string            // Docker 镜像名称
	Command        []string          // 命令参数
	Env            []string          // 容器环境变量
	PortMappings   map[string]string // 端口映射配置
	ContainerName  string            // 容器名称
	VolumeMappings []VolumeMapping   // 数据映射
}

Option 结构体用于配置 Docker 容器创建的选项

type VolumeMapping added in v0.1.5

type VolumeMapping struct {
	Source   string // 本地主机路径
	Target   string // 容器内路径
	ReadOnly bool   // 是否为只读
}

添加 VolumeMapping 结构体用于配置数据卷映射

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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