docker

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package docker contains helpers for working with docker This package has no stability guarantees whatsoever!

Package docker contains helpers for working with docker This package has no stability guarantees whatsoever!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerCmder

func ContainerCmder(containerNameOrID string) exec.Cmder

ContainerCmder creates a new exec.Cmder against a docker container

func CopyFrom

func CopyFrom(containerNameOrID, srcPath, hostPath string) error

CopyFrom copies the file or dir in the container at srcPath to the host at hostPath

func CopyTo

func CopyTo(hostPath, containerNameOrID, destPath string) error

CopyTo copies the file at hostPath to the container at destPath

func EditArchiveRepositories added in v0.3.0

func EditArchiveRepositories(reader io.Reader, writer io.Writer, editRepositories func(string) string) error

EditArchiveRepositories applies edit to reader's image repositories, IE the repository part of repository:tag in image tags This supports v1 / v1.1 / v1.2 Docker Image Archives

editRepositories should be a function that returns the input or an edited form, where the input is the image repository

https://github.com/moby/moby/blob/master/image/spec/v1.md https://github.com/moby/moby/blob/master/image/spec/v1.1.md https://github.com/moby/moby/blob/master/image/spec/v1.2.md

func GetArchiveTags

func GetArchiveTags(path string) ([]string, error)

GetArchiveTags obtains a list of "repo:tag" docker image tags from a given docker image archive (tarball) path compatible with all known specs: https://github.com/moby/moby/blob/master/image/spec/v1.md https://github.com/moby/moby/blob/master/image/spec/v1.1.md https://github.com/moby/moby/blob/master/image/spec/v1.2.md

func ImageID added in v0.5.0

func ImageID(containerNameOrID string) (string, error)

ImageID return the Id of the container image

func ImageInspect added in v0.4.0

func ImageInspect(containerNameOrID, format string) ([]string, error)

ImageInspect return low-level information on containers images

func Inspect

func Inspect(containerNameOrID, format string) ([]string, error)

Inspect return low-level information on containers

func Kill

func Kill(signal, containerNameOrID string) error

Kill sends the named signal to the container

func NetworkInspect added in v0.4.0

func NetworkInspect(networkNames []string, format string) ([]string, error)

NetworkInspect displays detailed information on one or more networks

func Pull

func Pull(image string, retries int) error

Pull pulls an image, retrying up to retries times

func PullIfNotPresent

func PullIfNotPresent(image string, retries int) (pulled bool, err error)

PullIfNotPresent will pull an image if it is not present locally retrying up to retries times it returns true if it attempted to pull, and any errors from pulling

func Run

func Run(image string, opts ...RunOpt) error

Run creates a container with "docker run", with some error handling

func Save

func Save(image, dest string) error

Save saves image to dest, as in `docker save`

func SplitImage added in v0.5.0

func SplitImage(image string) (registry, tag string, err error)

SplitImage splits an image into (registry,tag) following these cases:

alpine -> (alpine, latest)

alpine:latest -> (alpine, latest)

alpine@sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913 -> (alpine, latest@sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913)

alpine:latest@sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913 -> (alpine, latest@sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913)

NOTE: for our purposes we consider the sha to be part of the tag, and we resolve the implicit :latest

func UsernsRemap

func UsernsRemap() bool

UsernsRemap checks if userns-remap is enabled in dockerd

Types

type RunOpt

type RunOpt func(*runOpts) *runOpts

RunOpt is an option for Run

func WithContainerArgs

func WithContainerArgs(args ...string) RunOpt

WithContainerArgs sets the args to the container as in the containerArgs portion of `docker run args... image containerArgs...` NOTE: this is only the args portion before the image

func WithMounts

func WithMounts(mounts []cri.Mount) RunOpt

WithMounts sets the container mounts

func WithPortMappings added in v0.4.0

func WithPortMappings(portMappings []cri.PortMapping) RunOpt

WithPortMappings sets the container port mappings to the host

func WithRunArgs

func WithRunArgs(args ...string) RunOpt

WithRunArgs sets the args for docker run as in the args portion of `docker run args... image containerArgs...`

Jump to

Keyboard shortcuts

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