docker

package module
v0.0.0-...-429928f Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 19 Imported by: 5

README

docker

docker manager

Documentation

Overview

Package docker Date: 2024/07/09 14:13:38 Author: Amu Description:

Package docker Date: 2024/07/09 14:13:56 Author: Amu Description:

Package docker Date: 2024/07/09 14:14:10 Author: Amu Description:

Package docker Date: 2024/07/09 14:13:06 Author: Amu Description:

Package docker Date: 2024/07/09 14:14:31 Author: Amu Description:

Package docker Date: 2024/07/09 14:19:40 Author: Amu Description:

Index

Constants

View Source
const (
	ServerTypeLabel = "server.type"
	CreatedByProbe  = "created.by.probe"
)
View Source
const (
	WebServer      = "web"
	HttpServer     = "http"
	DatabaseServer = "database"
	UnknownServer  = "unknown"
)

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
	Network      string            `json:"network"` // Network
	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
	Ports        []string          `json:"ports"`
	Volumes      []string          `json:"volumes"`
	Environments []string          `json:"environments"`
	Labels       map[string]string `json:"labels"`
}

type IManager

type IManager interface {
	Version(context.Context) (*Version, error)

	ListContainer(ctx context.Context) ([]ContainerSummary, error)
	HasSameNameContainer(ctx context.Context, containerName string) (bool, error)
	CreateContainer(ctx context.Context, containerName, imageName, networkName string, ports []string, vols []string, env []string, commands []string, labels map[string]string) (string, error)
	StartContainer(ctx context.Context, containerID string) error
	StopContainer(ctx context.Context, containerID string) error
	RestartContainer(ctx context.Context, containerID string) error
	DeleteContainer(ctx context.Context, containerID string) error
	CopyFileToContainer(ctx context.Context, containerID string, srcFile, dstFile string) error
	GetContainerMem(ctx context.Context, containerID string) (float64, float64, float64, error)
	GetContainerCpu(ctx context.Context, containerID string) (float64, error)
	GetContainerIDByContainerName(ctx context.Context, containerName string) (string, error)
	ContainerLogs(ctx context.Context, containerID string) (io.ReadCloser, error)
	RenameContainer(ctx context.Context, containerID, newName string) error

	ListImage(ctx context.Context) ([]ImageSummary, error)
	DeleteImage(ctx context.Context, imageID string) error
	PruneImages(ctx context.Context) error
	SearchImage(ctx context.Context, imageName string) ([]registry.SearchResult, error)
	PullImage(ctx context.Context, imageName string) error
	TagImage(ctx context.Context, oldTag, newTag string) error
	ImportImage(ctx context.Context, sourceFile string) error
	ExportImage(ctx context.Context, imageIDs []string, targetFile string) error
	GetImageByName(ctx context.Context, imageName string) (*ImageSummary, error)
	GetImageByID(ctx context.Context, imageID string) (*ImageSummary, error)

	ListNetwork(ctx context.Context) ([]NetworkSummary, error)
	HasSameNameNetwork(ctx context.Context, networkName string) (bool, error)
	CreateNetwork(ctx context.Context, name, driver, subnet, gateway string, labels map[string]string) (string, error)
	GetNetworkByID(ctx context.Context, networkID string) (*NetworkSummary, error)
	DeleteNetwork(ctx context.Context, networkID string) error
	PruneNetwork(ctx context.Context) error
	JoinNetwork(ctx context.Context, containerID, networkID string) error
	LeaveNetwork(ctx context.Context, containerID, networkID string) error
}

type ImageSummary

type ImageSummary struct {
	ID      string
	Name    string
	Tag     string
	Created string
	Size    string
}

type Manager

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

func NewManager

func NewManager() (*Manager, error)

func (*Manager) ContainerExists

func (m *Manager) ContainerExists(ctx context.Context, containerID string) (bool, error)

func (*Manager) ContainerLogs

func (m *Manager) ContainerLogs(ctx context.Context, containerID string) (io.ReadCloser, error)

func (*Manager) CopyFileToContainer

func (m *Manager) CopyFileToContainer(ctx context.Context, containerID string, srcFile, dstFile string) error

func (*Manager) CreateContainer

func (m *Manager) CreateContainer(ctx context.Context, containerName, imageName, networkName string, ports []string, vols []string, envs []string, commands []string, labels map[string]string) (string, error)

func (*Manager) CreateNetwork

func (m *Manager) CreateNetwork(ctx context.Context, name, driver, subnet, gateway string, labels map[string]string) (string, error)

func (*Manager) DeleteContainer

func (m *Manager) DeleteContainer(ctx context.Context, containerID string) error

func (*Manager) DeleteImage

func (m *Manager) DeleteImage(ctx context.Context, imageID string) error

func (*Manager) DeleteNetwork

func (m *Manager) DeleteNetwork(ctx context.Context, networkID string) error

func (*Manager) ExportImage

func (m *Manager) ExportImage(ctx context.Context, imageIDs []string, targetFile string) error

func (*Manager) GetContainerCpu

func (m *Manager) GetContainerCpu(ctx context.Context, containerID string) (float64, error)

func (*Manager) GetContainerIDByContainerName

func (m *Manager) GetContainerIDByContainerName(ctx context.Context, containerName string) (string, error)

func (*Manager) GetContainerMem

func (m *Manager) GetContainerMem(ctx context.Context, containerID string) (float64, float64, float64, error)

func (*Manager) GetImageByID

func (m *Manager) GetImageByID(ctx context.Context, imageID string) (*ImageSummary, error)

func (*Manager) GetImageByName

func (m *Manager) GetImageByName(ctx context.Context, imageName string) (*ImageSummary, error)

func (*Manager) GetNetworkByID

func (m *Manager) GetNetworkByID(ctx context.Context, networkID string) (*NetworkSummary, error)

func (*Manager) GetNetworkByName

func (m *Manager) GetNetworkByName(ctx context.Context, name string) (*NetworkSummary, error)

func (*Manager) HasSameNameContainer

func (m *Manager) HasSameNameContainer(ctx context.Context, containerName string) (bool, error)

func (*Manager) HasSameNameNetwork

func (m *Manager) HasSameNameNetwork(ctx context.Context, networkName string) (bool, error)

func (*Manager) ImportImage

func (m *Manager) ImportImage(ctx context.Context, sourceFile string) error

func (*Manager) JoinNetwork

func (m *Manager) JoinNetwork(ctx context.Context, containerID, networkID string) error

func (*Manager) LeaveNetwork

func (m *Manager) LeaveNetwork(ctx context.Context, containerID, networkID string) error

func (*Manager) ListContainer

func (m *Manager) ListContainer(ctx context.Context) ([]ContainerSummary, error)

func (*Manager) ListImage

func (m *Manager) ListImage(ctx context.Context) ([]ImageSummary, error)

func (*Manager) ListNetwork

func (m *Manager) ListNetwork(ctx context.Context) ([]NetworkSummary, error)

func (*Manager) PruneImages

func (m *Manager) PruneImages(ctx context.Context) error

func (*Manager) PruneNetwork

func (m *Manager) PruneNetwork(ctx context.Context) error

func (*Manager) PullImage

func (m *Manager) PullImage(ctx context.Context, imageName string) error

func (*Manager) RenameContainer

func (m *Manager) RenameContainer(ctx context.Context, containerID, newName string) error

func (*Manager) RestartContainer

func (m *Manager) RestartContainer(ctx context.Context, containerID string) error

func (*Manager) SearchImage

func (m *Manager) SearchImage(ctx context.Context, imageName string) ([]registry.SearchResult, error)

func (*Manager) StartContainer

func (m *Manager) StartContainer(ctx context.Context, containerID string) error

func (*Manager) StopContainer

func (m *Manager) StopContainer(ctx context.Context, containerID string) error

func (*Manager) TagImage

func (m *Manager) TagImage(ctx context.Context, oldTag, newTag string) error

func (*Manager) Version

func (m *Manager) Version(ctx context.Context) (*Version, error)

type NetworkSummary

type NetworkSummary struct {
	ID         string
	Name       string
	Driver     string
	Scope      string
	Created    string
	Internal   bool
	SubNet     []SubNetworkConfig
	Containers map[string]string // map[cid]ipaddr
	Labels     map[string]string
}

type PortMapping

type PortMapping struct {
	Proto         string
	IP            string
	HostPort      string
	ContainerPort string
}

type SubNetworkConfig

type SubNetworkConfig struct {
	Subnet  string
	Gateway string
}

type Version

type Version struct {
	DockerVersion string `json:"docker_version"`
	APIVersion    string `json:"api_version"`
	MinAPIVersion string `json:"min_api_version"`
	GitCommit     string `json:"git_commit"`
	GoVersion     string `json:"go_version"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
}

Jump to

Keyboard shortcuts

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