docker

package
v0.0.0-...-721006d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

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

Container wraps a Docker container in the common runtime interface.

func (*Container) Attach

Attach hijacks the IO streams of a container. This must be called before the container is started.

func (*Container) Commit

func (c *Container) Commit(ctx context.Context) (string, error)

Commit the image, saving the contents of the root filesystem as a layer. Returns the SHA of the created image.

func (*Container) Exec

func (c *Container) Exec(ctx context.Context, opts *ExecOpts) error

func (*Container) Info

Info returns a container's details.

func (*Container) Logs

func (c *Container) Logs(ctx context.Context, since time.Time) (logging.LogReader, error)

Logs returns logging.LogReader which can be used to read log messages starting at the given time (inclusive). Set time to zero to read the full log.

func (*Container) Name

func (c *Container) Name() string

Name returns the container's unique ID.

func (*Container) Remove

func (c *Container) Remove(ctx context.Context) error

Remove kills and removes a container with no grace period.

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

Start calls the entrypoint in a created container.

func (*Container) Stats

Stats scrapes stats information about the container and returns it. This includes information about memory, cpu, network and block IO.

func (*Container) Stop

func (c *Container) Stop(ctx context.Context, timeout *time.Duration) error

Stop sends a SIGTERM to a container to instruct it to exit. If a timeout is provided and elapses, the container is forcibly stopped with SIGKILL.

func (*Container) Stream

func (c *Container) Stream(ctx context.Context, resp types.HijackedResponse) error

Stream connects to a container with an interactive prompt. Use Attach to get the hijacked response. This must be called after the container is started. This is a borrowed and cleaned up version of the Docker CLI implementation.

type ExecOpts

type ExecOpts struct {
	// (required) Command and arguments.
	Command []string

	// (optional) Environment variables.
	Env map[string]string

	// (optional) User that will run the command.
	// Defaults to the user of the container's root process.
	User string

	// (optional) WorkingDir where the command will be launched.
	// Defaults to the container's working dir.
	WorkingDir string
}

type LogReader

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

LogReader translates streamed Docker logs into discrete, structured log messages. This reader is not safe for concurrent use.

func NewLogReader

func NewLogReader(r io.Reader) *LogReader

NewLogReader wraps a streaming Docker log reader. The provided reader must include timestamps.

The reader introduces its own buffering and may read data from r beyond the bytes requested by Read().

func (*LogReader) Close

func (r *LogReader) Close() error

Close implements the io.Closer interface.

func (*LogReader) ReadMessage

func (r *LogReader) ReadMessage() (*logging.Message, error)

ReadMessage implements the logging.LogReader interface.

type Runtime

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

Runtime wraps the Docker runtime in a common interface.

func NewRuntime

func NewRuntime() (*Runtime, error)

NewRuntime creates a new Docker-backed Runtime.

func (*Runtime) Close

func (r *Runtime) Close() error

Close implements the io.Closer interface.

func (*Runtime) Container

func (r *Runtime) Container(id string) runtime.Container

Container creates an interface to an existing container.

func (*Runtime) CreateContainer

func (r *Runtime) CreateContainer(
	ctx context.Context,
	opts *runtime.ContainerOpts,
) (runtime.Container, error)

CreateContainer creates a new container. Call Start to run it.

func (*Runtime) ListContainers

func (r *Runtime) ListContainers(ctx context.Context) ([]runtime.Container, error)

ListContainers enumerates all containers.

func (*Runtime) PullImage

func (r *Runtime) PullImage(
	ctx context.Context,
	image *runtime.DockerImage,
	policy runtime.PullPolicy,
	quiet bool,
) error

PullImage pulls a Docker image and prints progress to stdout unless quiet is set.

func (*Runtime) PushImage

func (r *Runtime) PushImage(
	ctx context.Context,
	image *runtime.DockerImage,
	quiet bool,
) error

PushImage pushes a Docker image and prints progress to stdout unless quiet is set.

func (*Runtime) TagImage

func (r *Runtime) TagImage(ctx context.Context, source string, target string) error

TagImage tags the source image as the target.

Jump to

Keyboard shortcuts

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