Documentation
¶
Index ¶
- Constants
- type Client
- type ClientConfig
- type Container
- type ContainerClient
- type ContainerLog
- type ContainerTerminal
- type DockerClient
- func (d *DockerClient) Close() error
- func (d *DockerClient) CommitContainer(ctx context.Context, containerID, imageName string) (id string, err error)
- func (d *DockerClient) CreateContainer(ctx context.Context, r Container) (containerID string, err error)
- func (d *DockerClient) CreateNetwork(ctx context.Context, name string, options network.CreateOptions) error
- func (d *DockerClient) DeleteContainer(ctx context.Context, containerID string) error
- func (d *DockerClient) ExecContainer(ctx context.Context, containerID string, cmd string) ([]byte, error)
- func (d *DockerClient) GetNetwork(ctx context.Context, name string) error
- func (d *DockerClient) InspectContainer(ctx context.Context, containerID string) (*types.ContainerJSON, error)
- func (d *DockerClient) InspectImage(ctx context.Context, id string) (types.ImageInspect, error)
- func (d *DockerClient) ListContainer(ctx context.Context, opt container.ListOptions) ([]types.Container, error)
- func (d *DockerClient) LogContainer(ctx context.Context, log ContainerLog) (string, error)
- func (d *DockerClient) LogContainerStream(ctx context.Context, log ContainerLog) (chan string, error)
- func (d *DockerClient) PullImage(ctx context.Context, imageName string, auth *ImageAuth) error
- func (d *DockerClient) PushImage(ctx context.Context, imageName string, auth *ImageAuth) error
- func (d *DockerClient) RestartContainer(ctx context.Context, containerID string) error
- func (d *DockerClient) StartContainer(ctx context.Context, containerID string) error
- func (d *DockerClient) StopContainer(ctx context.Context, containerID string) error
- func (d *DockerClient) TerminalContainer(ctx context.Context, tty *ContainerTerminal) (chan []byte, error)
- type DockerConfig
- type ImageAuth
- type ImageClient
- type NetworkClient
- type Volume
Constants ¶
View Source
const ( HostVolume = "host" NFSVolume = "nfs" BindVolume = "bind" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
ContainerClient
ImageClient
NetworkClient
Close() error
}
func NewClient ¶
func NewClient(host string, cfg ClientConfig) (Client, error)
NewClient 创建 Docker 客户端
func NewDockerClient ¶
func NewDockerClient(host string, cfg ClientConfig) (Client, error)
type ClientConfig ¶
type ClientConfig struct {
DockerConfig *DockerConfig `json:"docker"`
VolImage string `json:"vol_image"`
}
type Container ¶
type Container struct {
Name string // only allow letters, numbers, and hyphens
PullImage bool
ImageAuth *ImageAuth
Image string
Command []string
EntryPoint []string
Labels map[string]string
CPU float32 // cpu cores
Memory float32 // memory in GB
ShmSize float32 // shm size in GB
Ports []string // ports
Environment []string // environment variables
Volumes []Volume
Links []string
NetworkName string
HostNetwork bool
HostIpcMode bool
Privileged bool
Runtime string
IsRemove bool
Restart string
WorkDir string
Hosts []string
User string // user to run the container, e.g. "root"
}
type ContainerClient ¶
type ContainerClient interface {
CreateContainer(ctx context.Context, r Container) (containerID string, err error)
DeleteContainer(ctx context.Context, containerID string) error
StartContainer(ctx context.Context, containerID string) error
StopContainer(ctx context.Context, containerID string) error
RestartContainer(ctx context.Context, containerID string) error
LogContainer(ctx context.Context, log ContainerLog) (string, error)
LogContainerStream(ctx context.Context, log ContainerLog) (chan string, error)
TerminalContainer(ctx context.Context, tty *ContainerTerminal) (chan []byte, error)
ExecContainer(ctx context.Context, containerID string, cmd string) ([]byte, error)
InspectContainer(ctx context.Context, containerID string) (*types.ContainerJSON, error)
ListContainer(ctx context.Context, opt container.ListOptions) ([]types.Container, error)
CommitContainer(ctx context.Context, containerID string, imageName string) (string, error)
InspectImage(ctx context.Context, id string) (types.ImageInspect, error)
}
type ContainerLog ¶
type ContainerTerminal ¶
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
implement ContainerClient interface
func (*DockerClient) Close ¶
func (d *DockerClient) Close() error
func (*DockerClient) CommitContainer ¶
func (d *DockerClient) CommitContainer(ctx context.Context, containerID, imageName string) (id string, err error)
CommitContainer save container as image
func (*DockerClient) CreateContainer ¶
func (*DockerClient) CreateNetwork ¶
func (d *DockerClient) CreateNetwork(ctx context.Context, name string, options network.CreateOptions) error
func (*DockerClient) DeleteContainer ¶
func (d *DockerClient) DeleteContainer(ctx context.Context, containerID string) error
DeleteContainer delete container
func (*DockerClient) ExecContainer ¶
func (*DockerClient) GetNetwork ¶
func (d *DockerClient) GetNetwork(ctx context.Context, name string) error
func (*DockerClient) InspectContainer ¶
func (d *DockerClient) InspectContainer(ctx context.Context, containerID string) (*types.ContainerJSON, error)
func (*DockerClient) InspectImage ¶
func (d *DockerClient) InspectImage(ctx context.Context, id string) (types.ImageInspect, error)
func (*DockerClient) ListContainer ¶
func (d *DockerClient) ListContainer(ctx context.Context, opt container.ListOptions) ([]types.Container, error)
func (*DockerClient) LogContainer ¶
func (d *DockerClient) LogContainer(ctx context.Context, log ContainerLog) (string, error)
func (*DockerClient) LogContainerStream ¶
func (d *DockerClient) LogContainerStream(ctx context.Context, log ContainerLog) (chan string, error)
func (*DockerClient) RestartContainer ¶
func (d *DockerClient) RestartContainer(ctx context.Context, containerID string) error
RestartContainer restart container
func (*DockerClient) StartContainer ¶
func (d *DockerClient) StartContainer(ctx context.Context, containerID string) error
StartContainer start container
func (*DockerClient) StopContainer ¶
func (d *DockerClient) StopContainer(ctx context.Context, containerID string) error
StopContainer stop container
func (*DockerClient) TerminalContainer ¶
func (d *DockerClient) TerminalContainer(ctx context.Context, tty *ContainerTerminal) (chan []byte, error)
type DockerConfig ¶
type ImageClient ¶
type NetworkClient ¶
Click to show internal directories.
Click to hide internal directories.