Package docker

import "github.com/chaos-mesh/chaos-mesh/pkg/chaosdaemon/crclients/docker"

Overview ▾

type DockerClient

DockerClient can get information from docker

type DockerClient struct {
    // contains filtered or unexported fields

func New

func New(host string, version string, client *http.Client, httpHeaders map[string]string) (*DockerClient, error)

func (DockerClient) ContainerKillByContainerID

func (c DockerClient) ContainerKillByContainerID(ctx context.Context, containerID string) error

ContainerKillByContainerID kills container according to container id

func (DockerClient) FormatContainerID

func (c DockerClient) FormatContainerID(ctx context.Context, containerID string) (string, error)

FormatContainerID strips protocol prefix from the container ID

func (DockerClient) GetLabelsFromContainerID

func (c DockerClient) GetLabelsFromContainerID(ctx context.Context, containerID string) (map[string]string, error)

GetLabelsFromContainerID returns the labels according to container ID

func (DockerClient) GetPidFromContainerID

func (c DockerClient) GetPidFromContainerID(ctx context.Context, containerID string) (uint32, error)

GetPidFromContainerID fetches PID according to container id

func (DockerClient) ListContainerIDs

func (c DockerClient) ListContainerIDs(ctx context.Context) ([]string, error)

ListContainerIDs lists all container IDs

type DockerClientInterface

DockerClientInterface represents the DockerClient, it's used to simply unit test

type DockerClientInterface interface {
    ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
    ContainerKill(ctx context.Context, containerID, signal string) error
    ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)