containerutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: Apache-2.0 Imports: 46 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	UtsNamespaceHost = "host"
)

Variables

This section is empty.

Functions

func ContainerNetNSPath added in v1.2.0

func ContainerNetNSPath(ctx context.Context, c containerd.Container) (string, error)

ContainerNetNSPath returns the netns path of a container.

func ContainerStateDirPath added in v1.3.0

func ContainerStateDirPath(ns, dataStore, id string) (string, error)

ContainerStateDirPath returns the path to the Nerdctl-managed state directory for the container with the given ID.

func ContainerStatus added in v1.2.0

func ContainerStatus(ctx context.Context, c containerd.Container) (containerd.Status, error)

ContainerStatus returns the container's status from its task.

func CopyFiles added in v1.2.1

func CopyFiles(ctx context.Context, container2host bool, pid int, dst, src string, followSymlink bool) error

CopyFiles implements `nerdctl cp`.

See https://docs.docker.com/engine/reference/commandline/cp/ for the specification.

func GenerateSharingPIDOpts added in v1.2.0

func GenerateSharingPIDOpts(ctx context.Context, targetCon containerd.Container) ([]oci.SpecOpts, error)

GenerateSharingPIDOpts returns the oci.SpecOpts that shares the host linux namespace from `targetCon` If `targetCon` doesn't have a `PIDNamespace`, a new one is generated from its `Pid`.

func NetworkOptionsFromSpec added in v1.3.0

func NetworkOptionsFromSpec(spec *specs.Spec) (types.NetworkOptions, error)

Returns the NetworkOptions used in a container's creation from its spec.Annotations.

func Pause added in v1.2.0

func Pause(ctx context.Context, client *containerd.Client, id string) error

Pause pauses a container by its id.

func PrintHostPort

func PrintHostPort(ctx context.Context, writer io.Writer, container containerd.Container, containerPort int, proto string) error

PrintHostPort writes to `writer` the public (HostIP:HostPort) of a given `containerPort/protocol` in a container. if `containerPort < 0`, it writes all public ports of the container.

func ReconfigNetContainer added in v1.2.0

func ReconfigNetContainer(ctx context.Context, c containerd.Container, client *containerd.Client, lab map[string]string) error

ReconfigNetContainer reconfigures the container's network namespace path.

func ReconfigPIDContainer added in v1.2.0

func ReconfigPIDContainer(ctx context.Context, c containerd.Container, client *containerd.Client, lab map[string]string) error

ReconfigPIDContainer reconfigures the container's spec options for sharing PID namespace.

func Start added in v1.2.0

func Start(ctx context.Context, container containerd.Container, flagA bool, client *containerd.Client) (err error)

Start starts `container` with `attach` flag. If `attach` is true, it will attach to the container's stdio.

func Stop added in v1.2.0

func Stop(ctx context.Context, container containerd.Container, timeout *time.Duration) (err error)

Stop stops `container` by sending SIGTERM. If the container is not stopped after `timeout`, it sends a SIGKILL.

func Unpause added in v1.2.1

func Unpause(ctx context.Context, client *containerd.Client, id string) error

Unpause unpauses a container by its id.

func UpdateErrorLabel added in v1.3.0

func UpdateErrorLabel(ctx context.Context, container containerd.Container, err error) error

UpdateErrorLabel updates the "nerdctl/error" label of the container according to the container error.

func UpdateExplicitlyStoppedLabel added in v1.2.0

func UpdateExplicitlyStoppedLabel(ctx context.Context, container containerd.Container, explicitlyStopped bool) error

UpdateExplicitlyStoppedLabel updates the "containerd.io/restart.explicitly-stopped" label of the container according to the value of explicitlyStopped.

func WithBindMountHostProcfs added in v1.2.0

func WithBindMountHostProcfs(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error

WithBindMountHostProcfs replaces procfs mount with rbind. Required for --pid=host on rootless.

https://github.com/moby/moby/pull/41893/files https://github.com/containers/podman/blob/v3.0.0-rc1/pkg/specgen/generate/oci.go#L248-L257

Types

type NetworkOptionsManager added in v1.3.0

type NetworkOptionsManager interface {
	// Returns a copy of the internal types.NetworkOptions.
	NetworkOptions() types.NetworkOptions

	// Verifies that the internal network settings are correct.
	VerifyNetworkOptions(context.Context) error

	// Performs setup actions required for the container with the given ID.
	SetupNetworking(context.Context, string) error

	// Performs any required cleanup actions for the given container.
	// Should only be called to revert any setup steps performed in SetupNetworking.
	CleanupNetworking(context.Context, containerd.Container) error

	// Returns the set of NetworkingOptions which should be set as labels on the container.
	//
	// These options can potentially differ from the actual networking options
	// that the NetworkOptionsManager was initially instantiated with.
	// E.g: in container networking mode, the label will be normalized to an ID:
	// `--net=container:myContainer` => `--net=container:<ID of myContainer>`.
	InternalNetworkingOptionLabels(context.Context) (types.NetworkOptions, error)

	// Returns a slice of `oci.SpecOpts` and `containerd.NewContainerOpts` which represent
	// the network specs which need to be applied to the container with the given ID.
	ContainerNetworkingOpts(context.Context, string) ([]oci.SpecOpts, []containerd.NewContainerOpts, error)
}

types.NetworkOptionsManager is an interface for reading/setting networking options for containers based on the provided command flags.

func NewNetworkingOptionsManager added in v1.3.0

func NewNetworkingOptionsManager(globalOptions types.GlobalCommandOptions, netOpts types.NetworkOptions) (NetworkOptionsManager, error)

Returns a types.NetworkOptionsManager based on the provided command's flags.

Jump to

Keyboard shortcuts

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