containerd

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MulanPSL-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerdConfigFilePath = "/etc/containerd/config.toml"
View Source
const (
	// IDLength specifies the length of the hexadecimal string ID
	IDLength = 64
)

Variables

View Source
var (
	// Timeout  of connecting to server (default: 10s)
	Timeout = 10 * time.Second
)

Functions

func GenerateID

func GenerateID() string

GenerateID creates a secure random hexadecimal string of IDLength characters

func GetAddressAndDialer

func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error)

GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer.

func GetContainerdConfig

func GetContainerdConfig(path string) (*srvconfig.Config, error)

func WaitContainerdReady

func WaitContainerdReady() error

Types

type Client

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

func (*Client) Close

func (c *Client) Close()

func (*Client) ContainerList

func (c *Client) ContainerList(filters ...string) ([]containerd.Container, error)

func (*Client) Delete

func (c *Client) Delete(name string) error

Delete deletes a container. todo 该方法存在bug 未完全解决,暂且删除容器使用exec的方式

func (*Client) EnsureContainerRun

func (c *Client) EnsureContainerRun(containerId string) (bool, error)

func (*Client) EnsureImageExists

func (c *Client) EnsureImageExists(image ImageRef) error

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) Pull

func (c *Client) Pull(image ImageRef) error

func (*Client) Run

func (c *Client) Run(cs ContainerSpec) error

func (*Client) Stop

func (c *Client) Stop(id string) error

type ContainerSpec

type ContainerSpec struct {
	Image       string            `json:"image"`
	Args        []string          `json:"args"`
	Env         []string          `json:"env"`
	Mount       []specs.Mount     `json:"mount"`
	Privileged  bool              `json:"privileged"`
	HostNetwork bool              `json:"hostNetwork"`
	Annotation  map[string]string `json:"annotation"`
}

type ContainerdClient

type ContainerdClient interface {
	Pull(Image ImageRef) error
	//Push(Image ImageRef) (readClose io.ReadCloser, err error)
	Close()
	Stop(containerId string) error
	Delete(containerId string) error
	Run(cs ContainerSpec) error
	EnsureImageExists(image ImageRef) error
	EnsureContainerRun(containerId string) (bool, error)
	ContainerList(filters ...string) ([]containerd.Container, error)
	Ping() error
}

func NewContainedClient

func NewContainedClient() (ContainerdClient, error)

type ImageRef

type ImageRef struct {
	Image    string `json:"image"`
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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