daemon

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2015 License: Apache-2.0 Imports: 105 Imported by: 0

README

This directory contains code pertaining to running containers and storing images

Code pertaining to running containers:

  • execdriver

Code pertaining to storing images:

  • graphdriver

Documentation

Overview

Package daemon exposes the functions that occur on the host server that the Docker daemon is running.

In implementing the various functions of the daemon, there is often a method-specific struct for configuring the runtime behavior.

Index

Constants

View Source
const (
	// NetworkByID represents a constant to find a network by its ID
	NetworkByID = iota + 1
	// NetworkByName represents a constant to find a network by its Name
	NetworkByName
)
View Source
const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

DefaultPathEnv is unix style list of directories to search for executables. Each directory is separated from the next by a colon ':' character .

Variables

View Source
var ErrExtractPointNotDirectory = errors.New("extraction point is not a directory")

ErrExtractPointNotDirectory is used to convey that the operation to extract a tar archive to a directory in a container has failed because the specified path does not refer to a directory.

View Source
var (
	// ErrRootFSReadOnly is returned when a container
	// rootfs is marked readonly.
	ErrRootFSReadOnly = errors.New("container rootfs is marked read-only")
)
View Source
var (
	// ErrVolumeReadonly is used to signal an error when trying to copy data into
	// a volume mount that is not writable.
	ErrVolumeReadonly = errors.New("mounted volume is marked read-only")
)

Functions

func GetFullContainerName

func GetFullContainerName(name string) (string, error)

GetFullContainerName returns a constructed container name. I think it has to do with the fact that a container is a file on disk and this is sort of just creating a file name.

Types

type CommonConfig added in v1.7.0

type CommonConfig struct {
	AutoRestart    bool
	Bridge         bridgeConfig // Bridge holds bridge network specific configuration.
	Context        map[string][]string
	DisableBridge  bool
	DNS            []string
	DNSOptions     []string
	DNSSearch      []string
	ExecDriver     string
	ExecOptions    []string
	ExecRoot       string
	GraphDriver    string
	GraphOptions   []string
	Labels         []string
	LogConfig      runconfig.LogConfig
	Mtu            int
	Pidfile        string
	RemappedRoot   string
	Root           string
	TrustKeyPath   string
	DefaultNetwork string

	// ClusterStore is the storage backend used for the cluster information. It is used by both
	// multihost networking (to store networks and endpoints information) and by the node discovery
	// mechanism.
	ClusterStore string

	// ClusterOpts is used to pass options to the discovery package for tuning libkv settings, such
	// as TLS configuration settings.
	ClusterOpts map[string]string

	// ClusterAdvertise is the network endpoint that the Engine advertises for the purpose of node
	// discovery. This should be a 'host:port' combination on which that daemon instance is
	// reachable by other hosts.
	ClusterAdvertise string
}

CommonConfig defines the configuration of a docker daemon which are common across platforms.

type CommonContainer added in v1.7.0

type CommonContainer struct {

	// embed for Container to support states directly.
	*State `json:"State"` // Needed for remote api version <= 1.11

	ID              string
	Created         time.Time
	Path            string
	Args            []string
	Config          *runconfig.Config
	ImageID         string `json:"Image"`
	NetworkSettings *network.Settings
	LogPath         string
	Name            string
	Driver          string
	ExecDriver      string
	// MountLabel contains the options for the 'mount' command
	MountLabel             string
	ProcessLabel           string
	RestartCount           int
	HasBeenStartedBefore   bool
	HasBeenManuallyStopped bool // used for unless-stopped restart policy
	// contains filtered or unexported fields
}

CommonContainer holds the fields for a container which are applicable across all platforms supported by the daemon.

func (*CommonContainer) StderrPipe added in v1.9.0

func (streamConfig *CommonContainer) StderrPipe() io.ReadCloser

func (*CommonContainer) StdinPipe added in v1.9.0

func (streamConfig *CommonContainer) StdinPipe() io.WriteCloser

func (*CommonContainer) StdoutPipe added in v1.9.0

func (streamConfig *CommonContainer) StdoutPipe() io.ReadCloser

type Config added in v1.2.0

type Config struct {
	CommonConfig

	CorsHeaders          string
	EnableCors           bool
	EnableSelinuxSupport bool
	RemappedRoot         string
	SocketGroup          string
	Ulimits              map[string]*ulimit.Ulimit
}

Config defines the configuration of a docker daemon. These are the configuration settings that you pass to the docker daemon when you launch it with say: `docker daemon -e lxc`

func (*Config) InstallCommonFlags added in v1.7.0

func (config *Config) InstallCommonFlags(cmd *flag.FlagSet, usageFn func(string) string)

InstallCommonFlags adds command-line options to the top-level flag parser for the current process. Subsequent calls to `flag.Parse` will populate config with values parsed from the command-line.

func (*Config) InstallFlags added in v1.2.0

func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) string)

InstallFlags adds command-line options to the top-level flag parser for the current process. Subsequent calls to `flag.Parse` will populate config with values parsed from the command-line.

type Container

type Container struct {
	CommonContainer

	AppArmorProfile string
	HostnamePath    string
	HostsPath       string
	ShmPath         string
	MqueuePath      string
	MountPoints     map[string]*mountPoint
	ResolvConfPath  string

	Volumes   map[string]string // Deprecated since 1.7, kept for backwards compatibility
	VolumesRW map[string]bool   // Deprecated since 1.7, kept for backwards compatibility
	// contains filtered or unexported fields
}

Container holds the fields specific to unixen implementations. See CommonContainer for standard fields common to all containers.

func (*Container) ArchivePath added in v1.8.0

func (container *Container) ArchivePath(path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)

ArchivePath creates an archive of the filesystem resource at the specified path in this container. Returns a tar archive of the resource and stat info about the resource.

func (*Container) Attach added in v1.7.0

func (container *Container) Attach(stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) chan error

Attach connects to the container's TTY, delegating to standard streams or websockets depending on the configuration.

func (*Container) ConnectToNetwork added in v1.9.0

func (container *Container) ConnectToNetwork(idOrName string) error

ConnectToNetwork connects a container to a network

func (*Container) DisconnectFromNetwork added in v1.9.0

func (container *Container) DisconnectFromNetwork(n libnetwork.Network) error

DisconnectFromNetwork disconnects a container from a network

func (*Container) ExtractToDir added in v1.8.0

func (container *Container) ExtractToDir(path string, noOverwriteDirNonDir bool, content io.Reader) (err error)

ExtractToDir extracts the given tar archive to the specified location in the filesystem of this container. The given path must be of a directory in the container. If it is not, the error will be ErrExtractPointNotDirectory. If noOverwriteDirNonDir is true then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non- directory and vice versa.

func (*Container) GetResourcePath added in v1.7.0

func (container *Container) GetResourcePath(path string) (string, error)

GetResourcePath evaluates `path` in the scope of the container's basefs, with proper path sanitisation. Symlinks are all scoped to the basefs of the container, as though the container's basefs was `/`.

The basefs of a container is the host-facing path which is bind-mounted as `/` inside the container. This method is essentially used to access a particular path inside the container as though you were a process in that container.

NOTE: The returned path is *only* safely scoped inside the container's basefs

if no component of the returned path changes (such as a component
symlinking to a different path) between using this method and using the
path. See symlink.FollowSymlinkInScope for more details.

func (*Container) Kill

func (container *Container) Kill() error

Kill forcefully terminates a container.

func (*Container) Mount

func (container *Container) Mount() error

Mount sets container.basefs

func (*Container) Resize

func (container *Container) Resize(h, w int) error

Resize changes the TTY of the process running inside the container to the given height and width. The container must be running.

func (*Container) Restart

func (container *Container) Restart(seconds int) error

Restart attempts to gracefully stop and then start the container. When stopping, wait for the given duration in seconds to gracefully stop, before forcefully terminating the container. If given a negative duration, wait forever for a graceful stop.

func (*Container) Start

func (container *Container) Start() (err error)

Start prepares the container to run by setting up everything the container needs, such as storage and networking, as well as links between containers. The container is left waiting for a signal to begin running.

func (*Container) StatPath added in v1.8.0

func (container *Container) StatPath(path string) (stat *types.ContainerPathStat, err error)

StatPath stats the filesystem resource at the specified path in this container. Returns stat info about the resource.

func (*Container) StderrPipe

func (streamConfig *Container) StderrPipe() io.ReadCloser

func (*Container) StdinPipe

func (streamConfig *Container) StdinPipe() io.WriteCloser

func (*Container) StdoutPipe

func (streamConfig *Container) StdoutPipe() io.ReadCloser

func (*Container) Stop

func (container *Container) Stop(seconds int) error

Stop halts a container by sending a stop signal, waiting for the given duration in seconds, and then calling SIGKILL and waiting for the process to exit. If a negative duration is given, Stop will wait for the initial signal forever. If the container is not running Stop returns immediately.

func (*Container) Unmount

func (container *Container) Unmount() error

Unmount asks the daemon to release the layered filesystems that are mounted by the container.

type ContainerAttachWithLogsConfig added in v1.7.0

type ContainerAttachWithLogsConfig struct {
	InStream                       io.ReadCloser
	OutStream                      io.Writer
	UseStdin, UseStdout, UseStderr bool
	Logs, Stream                   bool
}

ContainerAttachWithLogsConfig holds the streams to use when connecting to a container to view logs.

type ContainerCommitConfig added in v1.7.0

type ContainerCommitConfig struct {
	Pause   bool
	Repo    string
	Tag     string
	Author  string
	Comment string
	Config  *runconfig.Config
}

ContainerCommitConfig contains build configs for commit operation, and is used when making a commit with the current state of the container.

type ContainerLogsConfig added in v1.7.0

type ContainerLogsConfig struct {
	// if true stream log output
	Follow bool
	// if true include timestamps for each line of log output
	Timestamps bool
	// return that many lines of log output from the end
	Tail string
	// filter logs by returning on those entries after this time
	Since time.Time
	// whether or not to show stdout and stderr as well as log entries.
	UseStdout, UseStderr bool
	OutStream            io.Writer
	Stop                 <-chan bool
}

ContainerLogsConfig holds configs for logging operations. Exists for users of the daemon to to pass it a logging configuration.

type ContainerRmConfig added in v1.7.0

type ContainerRmConfig struct {
	ForceRemove, RemoveVolume, RemoveLink bool
}

ContainerRmConfig is a holder for passing in runtime config.

type ContainerStatsConfig added in v1.8.0

type ContainerStatsConfig struct {
	Stream    bool
	OutStream io.Writer
	Stop      <-chan bool
	Version   version.Version
}

ContainerStatsConfig holds information for configuring the runtime behavior of a daemon.ContainerStats() call.

type ContainerWsAttachWithLogsConfig added in v1.7.0

type ContainerWsAttachWithLogsConfig struct {
	InStream             io.ReadCloser
	OutStream, ErrStream io.Writer
	Logs, Stream         bool
}

ContainerWsAttachWithLogsConfig attach with websockets, since all stream data is delegated to the websocket to handle there.

type ContainersConfig added in v1.7.0

type ContainersConfig struct {
	// if true show all containers, otherwise only running containers.
	All bool
	// show all containers created after this container id
	Since string
	// show all containers created before this container id
	Before string
	// number of containers to return at most
	Limit int
	// if true include the sizes of the containers
	Size bool
	// return only containers that match filters
	Filters string
}

ContainersConfig is the filtering specified by the user to iterate over containers.

type Daemon

type Daemon struct {
	ID string

	RegistryService *registry.Service
	EventsService   *events.Events
	// contains filtered or unexported fields
}

Daemon holds information about the Docker daemon.

func NewDaemon

func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemon, err error)

NewDaemon sets up everything for the daemon to be able to service requests from the webserver.

func (*Daemon) AuthenticateToRegistry added in v1.9.0

func (daemon *Daemon) AuthenticateToRegistry(authConfig *cliconfig.AuthConfig) (string, error)

AuthenticateToRegistry checks the validity of credentials in authConfig

func (*Daemon) Commit

func (daemon *Daemon) Commit(container *Container, c *ContainerCommitConfig) (*image.Image, error)

Commit creates a new filesystem image from the current state of a container. The image can optionally be tagged into a repository.

func (*Daemon) ContainerArchivePath added in v1.8.0

func (daemon *Daemon) ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)

ContainerArchivePath creates an archive of the filesystem resource at the specified path in the container identified by the given name. Returns a tar archive of the resource and whether it was a directory or a single file.

func (*Daemon) ContainerAttachWithLogs added in v1.7.0

func (daemon *Daemon) ContainerAttachWithLogs(prefixOrName string, c *ContainerAttachWithLogsConfig) error

ContainerAttachWithLogs attaches to logs according to the config passed in. See ContainerAttachWithLogsConfig.

func (*Daemon) ContainerChanges added in v1.2.0

func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error)

ContainerChanges returns a list of container fs changes

func (*Daemon) ContainerCopy added in v1.2.0

func (daemon *Daemon) ContainerCopy(name string, res string) (io.ReadCloser, error)

ContainerCopy performs a deprecated operation of archiving the resource at the specified path in the conatiner identified by the given name.

func (*Daemon) ContainerCreate added in v1.2.0

func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hostConfig *runconfig.HostConfig, adjustCPUShares bool) (types.ContainerCreateResponse, error)

ContainerCreate takes configs and creates a container.

func (*Daemon) ContainerExecCreate added in v1.3.0

func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, error)

ContainerExecCreate sets up an exec in a running container.

func (*Daemon) ContainerExecInspect added in v1.4.0

func (daemon *Daemon) ContainerExecInspect(id string) (*ExecConfig, error)

ContainerExecInspect returns low-level information about the exec command. An error is returned if the exec cannot be found.

func (*Daemon) ContainerExecResize added in v1.3.0

func (daemon *Daemon) ContainerExecResize(name string, height, width int) error

ContainerExecResize changes the size of the TTY of the process running in the exec with the given name to the given height and width.

func (*Daemon) ContainerExecStart added in v1.3.0

func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error

ContainerExecStart starts a previously set up exec instance. The std streams are set up.

func (*Daemon) ContainerExport added in v1.2.0

func (daemon *Daemon) ContainerExport(name string, out io.Writer) error

ContainerExport writes the contents of the container to the given writer. An error is returned if the container cannot be found.

func (*Daemon) ContainerExtractToDir added in v1.8.0

func (daemon *Daemon) ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error

ContainerExtractToDir extracts the given archive to the specified location in the filesystem of the container identified by the given name. The given path must be of a directory in the container. If it is not, the error will be ErrExtractPointNotDirectory. If noOverwriteDirNonDir is true then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa.

func (*Daemon) ContainerInspect added in v0.12.0

func (daemon *Daemon) ContainerInspect(name string, size bool) (*types.ContainerJSON, error)

ContainerInspect returns low-level information about a container. Returns an error if the container cannot be found, or if there is an error getting the data.

func (*Daemon) ContainerInspect120 added in v1.9.0

func (daemon *Daemon) ContainerInspect120(name string) (*v1p20.ContainerJSON, error)

ContainerInspect120 serializes the master version of a container into a json type.

func (*Daemon) ContainerInspectPre120 added in v1.8.0

func (daemon *Daemon) ContainerInspectPre120(name string) (*v1p19.ContainerJSON, error)

ContainerInspectPre120 gets containers for pre 1.20 APIs.

func (*Daemon) ContainerKill added in v1.2.0

func (daemon *Daemon) ContainerKill(name string, sig uint64) error

ContainerKill send signal to the container If no signal is given (sig 0), then Kill with SIGKILL and wait for the container to exit. If a signal is given, then just send it to the container and return.

func (*Daemon) ContainerLogs added in v1.2.0

func (daemon *Daemon) ContainerLogs(containerName string, config *ContainerLogsConfig) error

ContainerLogs hooks up a container's stdout and stderr streams configured with the given struct.

func (*Daemon) ContainerPause added in v1.2.0

func (daemon *Daemon) ContainerPause(name string) error

ContainerPause pauses a container

func (*Daemon) ContainerRename added in v1.5.0

func (daemon *Daemon) ContainerRename(oldName, newName string) error

ContainerRename changes the name of a container, using the oldName to find the container. An error is returned if newName is already reserved.

func (*Daemon) ContainerResize added in v1.2.0

func (daemon *Daemon) ContainerResize(name string, height, width int) error

ContainerResize changes the size of the TTY of the process running in the container with the given name to the given height and width.

func (*Daemon) ContainerRestart added in v1.2.0

func (daemon *Daemon) ContainerRestart(name string, seconds int) error

ContainerRestart stops and starts a container. It attempts to gracefully stop the container within the given timeout, forcefully stopping it if the timeout is exceeded. If given a negative timeout, ContainerRestart will wait forever until a graceful stop. Returns an error if the container cannot be found, or if there is an underlying error at any stage of the restart.

func (*Daemon) ContainerRm added in v1.3.0

func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error

ContainerRm removes the container id from the filesystem. An error is returned if the container is not found, or if the remove fails. If the remove succeeds, the container name is released, and network links are removed.

func (*Daemon) ContainerStart added in v1.2.0

func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConfig) error

ContainerStart starts a container.

func (*Daemon) ContainerStatPath added in v1.8.0

func (daemon *Daemon) ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)

ContainerStatPath stats the filesystem resource at the specified path in the container identified by the given name.

func (*Daemon) ContainerStats added in v1.5.0

func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStatsConfig) error

ContainerStats writes information about the container to the stream given in the config object.

func (*Daemon) ContainerStop added in v1.2.0

func (daemon *Daemon) ContainerStop(name string, seconds int) error

ContainerStop looks for the given container and terminates it, waiting the given number of seconds before forcefully killing the container. If a negative number of seconds is given, ContainerStop will wait for a graceful termination. An error is returned if the container is not found, is already stopped, or if there is a problem stopping the container.

func (*Daemon) ContainerTop added in v1.2.0

func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)

ContainerTop lists the processes running inside of the given container by calling ps with the given args, or with the flags "-ef" if no args are given. An error is returned if the container is not found, or is not running, or if there are any problems running ps, or parsing the output.

func (*Daemon) ContainerUnpause added in v1.2.0

func (daemon *Daemon) ContainerUnpause(name string) error

ContainerUnpause unpauses a container

func (*Daemon) ContainerWait added in v1.2.0

func (daemon *Daemon) ContainerWait(name string, timeout time.Duration) (int, error)

ContainerWait stops processing until the given container is stopped. If the container is not found, an error is returned. On a successful stop, the exit code of the container is returned. On a timeout, an error is returned. If you want to wait forever, supply a negative duration for the timeout.

func (*Daemon) ContainerWsAttachWithLogs added in v1.7.0

func (daemon *Daemon) ContainerWsAttachWithLogs(prefixOrName string, c *ContainerWsAttachWithLogsConfig) error

ContainerWsAttachWithLogs websocket connection

func (*Daemon) Containers added in v1.2.0

func (daemon *Daemon) Containers(config *ContainersConfig) ([]*types.Container, error)

Containers returns the list of containers to show given the user's filtering.

func (*Daemon) Create

func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.HostConfig, name string) (retC *Container, retErr error)

Create creates a new container from the given configuration with a given name.

func (*Daemon) CreateNetwork added in v1.9.0

func (daemon *Daemon) CreateNetwork(name, driver string, ipam network.IPAM, options map[string]string) (libnetwork.Network, error)

CreateNetwork creates a network with the given name, driver and other optional parameters

func (*Daemon) Exec added in v1.3.0

func (d *Daemon) Exec(c *Container, ExecConfig *ExecConfig, pipes *execdriver.Pipes, startCallback execdriver.DriverCallback) (int, error)

Exec calls the underlying exec driver to run

func (*Daemon) ExecExists added in v1.9.0

func (d *Daemon) ExecExists(name string) (bool, error)

ExecExists looks up the exec instance and returns a bool if it exists or not. It will also return the error produced by `getExecConfig`

func (*Daemon) ExecutionDriver

func (daemon *Daemon) ExecutionDriver() execdriver.Driver

ExecutionDriver returns the currently used driver for creating and starting execs in a container.

func (*Daemon) Exists

func (daemon *Daemon) Exists(id string) bool

Exists returns a true if a container of the specified ID or name exists, false otherwise.

func (*Daemon) ExportImage added in v1.9.0

func (daemon *Daemon) ExportImage(names []string, outStream io.Writer) error

ExportImage exports a list of images to the given output stream. The exported images are archived into a tar when written to the output stream. All images with the given tag and all versions containing the same tag are exported. names is the set of tags to export, and outStream is the writer which the images are written to.

func (*Daemon) FindNetwork added in v1.9.0

func (daemon *Daemon) FindNetwork(idName string) (libnetwork.Network, error)

FindNetwork function finds a network for a given string that can represent network name or id

func (*Daemon) Get

func (daemon *Daemon) Get(prefixOrName string) (*Container, error)

Get looks for a container using the provided information, which could be one of the following inputs from the caller:

  • A full container ID, which will exact match a container in daemon's list
  • A container name, which will only exact match via the GetByName() function
  • A partial container ID prefix (e.g. short ID) of any length that is unique enough to only return a single container object If none of these searches succeed, an error is returned

func (*Daemon) GetByName

func (daemon *Daemon) GetByName(name string) (*Container, error)

GetByName returns a container given a name.

func (*Daemon) GetEventFilter added in v1.9.0

func (daemon *Daemon) GetEventFilter(filter filters.Args) *events.Filter

GetEventFilter returns a filters.Filter for a set of filters

func (*Daemon) GetImage added in v1.9.0

func (daemon *Daemon) GetImage(name string) (*image.Image, error)

GetImage returns pointer to an Image struct corresponding to the given name. The name can include an optional tag; otherwise the default tag will be used.

func (*Daemon) GetLabels added in v1.9.0

func (daemon *Daemon) GetLabels(id string) map[string]string

GetLabels for a container or image id

func (*Daemon) GetNetwork added in v1.9.0

func (daemon *Daemon) GetNetwork(idName string, by int) (libnetwork.Network, error)

GetNetwork function returns a network for a given string that represents the network and a hint to indicate if the string is an Id or Name of the network

func (*Daemon) GetNetworksByID added in v1.9.0

func (daemon *Daemon) GetNetworksByID(partialID string) []libnetwork.Network

GetNetworksByID returns a list of networks whose ID partially matches zero or more networks

func (*Daemon) GetRemappedUIDGID added in v1.9.0

func (daemon *Daemon) GetRemappedUIDGID() (int, int)

GetRemappedUIDGID returns the current daemon's uid and gid values if user namespaces are in use for this daemon instance. If not this function will return "real" root values of 0, 0.

func (*Daemon) GetUIDGIDMaps added in v1.9.0

func (daemon *Daemon) GetUIDGIDMaps() ([]idtools.IDMap, []idtools.IDMap)

GetUIDGIDMaps returns the current daemon's user namespace settings for the full uid and gid maps which will be applied to containers started in this instance.

func (*Daemon) Graph

func (daemon *Daemon) Graph() *graph.Graph

Graph needs to be removed.

FIXME: this is a convenience function for integration tests which need direct access to daemon.graph. Once the tests switch to using engine and jobs, this method can go away.

func (*Daemon) GraphDriver

func (daemon *Daemon) GraphDriver() graphdriver.Driver

GraphDriver returns the currently used driver for processing container layers.

func (*Daemon) ImageDelete added in v1.2.0

func (daemon *Daemon) ImageDelete(imageRef string, force, prune bool) ([]types.ImageDelete, error)

ImageDelete deletes the image referenced by the given imageRef from this daemon. The given imageRef can be an image ID, ID prefix, or a repository reference (with an optional tag or digest, defaulting to the tag name "latest"). There is differing behavior depending on whether the given imageRef is a repository reference or not.

If the given imageRef is a repository reference then that repository reference will be removed. However, if there exists any containers which were created using the same image reference then the repository reference cannot be removed unless either there are other repository references to the same image or force is true. Following removal of the repository reference, the referenced image itself will attempt to be deleted as described below but quietly, meaning any image delete conflicts will cause the image to not be deleted and the conflict will not be reported.

There may be conflicts preventing deletion of an image and these conflicts are divided into two categories grouped by their severity:

Hard Conflict:

  • a pull or build using the image.
  • any descendent image.
  • any running container using the image.

Soft Conflict:

  • any stopped container using the image.
  • any repository tag or digest references to the image.

The image cannot be removed if there are any hard conflicts and can be removed if there are soft conflicts only if force is true.

If prune is true, ancestor images will each attempt to be deleted quietly, meaning any delete conflicts will cause the image to not be deleted and the conflict will not be reported.

FIXME: remove ImageDelete's dependency on Daemon, then move to the graph package. This would require that we no longer need the daemon to determine whether images are being used by a stopped or running container.

func (*Daemon) ImageGetCached added in v1.2.0

func (daemon *Daemon) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error)

ImageGetCached returns the earliest created image that is a child of the image with imgID, that had the same config when it was created. nil is returned if a child cannot be found. An error is returned if the parent image cannot be found.

func (*Daemon) ImageHistory added in v1.9.0

func (daemon *Daemon) ImageHistory(name string) ([]*types.ImageHistory, error)

ImageHistory returns a slice of ImageHistory structures for the specified image name by walking the image lineage.

func (*Daemon) ImportImage added in v1.9.0

func (daemon *Daemon) ImportImage(src, repo, tag, msg string, inConfig io.ReadCloser, outStream io.Writer, containerConfig *runconfig.Config) error

ImportImage imports an image, getting the archived layer data either from inConfig (if src is "-"), or from a URI specified in src. Progress output is written to outStream. Repository and tag names can optionally be given in the repo and tag arguments, respectively.

func (*Daemon) List

func (daemon *Daemon) List() []*Container

List returns an array of all containers registered in the daemon.

func (*Daemon) ListImages added in v1.9.0

func (daemon *Daemon) ListImages(filterArgs, filter string, all bool) ([]*types.Image, error)

ListImages returns a filtered list of images. filterArgs is a JSON-encoded set of filter arguments which will be interpreted by pkg/parsers/filters. filter is a shell glob string applied to repository names. The argument named all controls whether all images in the graph are filtered, or just the heads.

func (*Daemon) LoadImage added in v1.9.0

func (daemon *Daemon) LoadImage(inTar io.ReadCloser, outStream io.Writer) error

LoadImage uploads a set of images into the repository. This is the complement of ImageExport. The input stream is an uncompressed tar ball containing images and metadata.

func (*Daemon) LookupImage added in v1.9.0

func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error)

LookupImage looks up an image by name and returns it as an ImageInspect structure.

func (*Daemon) Mount

func (daemon *Daemon) Mount(container *Container) error

Mount sets container.basefs (is it not set coming in? why is it unset?)

func (*Daemon) NetworkControllerEnabled added in v1.9.0

func (daemon *Daemon) NetworkControllerEnabled() bool

NetworkControllerEnabled checks if the networking stack is enabled. This feature depends on OS primitives and it's dissabled in systems like Windows.

func (*Daemon) PullImage added in v1.9.0

func (daemon *Daemon) PullImage(image string, tag string, imagePullConfig *graph.ImagePullConfig) error

PullImage initiates a pull operation. image is the repository name to pull, and tag may be either empty, or indicate a specific tag to pull.

func (*Daemon) PushImage added in v1.9.0

func (daemon *Daemon) PushImage(localName string, imagePushConfig *graph.ImagePushConfig) error

PushImage initiates a push operation on the repository named localName.

func (*Daemon) Register

func (daemon *Daemon) Register(container *Container) error

Register makes a container object usable by the daemon as <container.ID>

func (*Daemon) SearchRegistryForImages added in v1.9.0

func (daemon *Daemon) SearchRegistryForImages(term string,
	authConfig *cliconfig.AuthConfig,
	headers map[string][]string) (*registry.SearchResults, error)

SearchRegistryForImages queries the registry for images matching term. authConfig is used to login.

func (*Daemon) Shutdown added in v1.7.0

func (daemon *Daemon) Shutdown() error

Shutdown stops the daemon.

func (*Daemon) SystemInfo added in v1.7.0

func (daemon *Daemon) SystemInfo() (*types.Info, error)

SystemInfo returns information about the host server the daemon is running on.

func (*Daemon) TagImage added in v1.9.0

func (daemon *Daemon) TagImage(repoName, tag, imageName string, force bool) error

TagImage creates a tag in the repository reponame, pointing to the image named imageName. If force is true, an existing tag with the same name may be overwritten.

func (*Daemon) VolumeCreate added in v1.9.0

func (daemon *Daemon) VolumeCreate(name, driverName string, opts map[string]string) (*types.Volume, error)

VolumeCreate creates a volume with the specified name, driver, and opts This is called directly from the remote API

func (*Daemon) VolumeInspect added in v1.9.0

func (daemon *Daemon) VolumeInspect(name string) (*types.Volume, error)

VolumeInspect looks up a volume by name. An error is returned if the volume cannot be found.

func (*Daemon) VolumeRm added in v1.9.0

func (daemon *Daemon) VolumeRm(name string) error

VolumeRm removes the volume with the given name. If the volume is referenced by a container it is not removed This is called directly from the remote API

func (*Daemon) Volumes

func (daemon *Daemon) Volumes(filter string) ([]*types.Volume, error)

Volumes lists known volumes, using the filter to restrict the range of volumes returned.

type ExecConfig added in v1.9.0

type ExecConfig struct {
	sync.Mutex
	ID            string
	Running       bool
	ExitCode      int
	ProcessConfig *execdriver.ProcessConfig

	OpenStdin  bool
	OpenStderr bool
	OpenStdout bool
	Container  *Container
	// contains filtered or unexported fields
}

ExecConfig holds the configurations for execs. The Daemon keeps track of both running and finished execs so that they can be examined both during and after completion.

func (*ExecConfig) StderrPipe added in v1.9.0

func (streamConfig *ExecConfig) StderrPipe() io.ReadCloser

func (*ExecConfig) StdinPipe added in v1.9.0

func (streamConfig *ExecConfig) StdinPipe() io.WriteCloser

func (*ExecConfig) StdoutPipe added in v1.9.0

func (streamConfig *ExecConfig) StdoutPipe() io.ReadCloser

type History

type History []*Container

History is a convenience type for storing a list of containers, ordered by creation date.

func (*History) Add

func (history *History) Add(container *Container)

Add the given container to history.

func (*History) Len

func (history *History) Len() int

func (*History) Less

func (history *History) Less(i, j int) bool

func (*History) Swap

func (history *History) Swap(i, j int)

type State

type State struct {
	sync.Mutex
	// FIXME: Why do we have both paused and running if a
	// container cannot be paused and running at the same time?
	Running    bool
	Paused     bool
	Restarting bool
	OOMKilled  bool

	Dead       bool
	Pid        int
	ExitCode   int
	Error      string // contains last known error when starting the container
	StartedAt  time.Time
	FinishedAt time.Time
	// contains filtered or unexported fields
}

State holds the current container state, and has methods to get and set the state. Container has an embed, which allows all of the functions defined against State to run against Container.

func NewState added in v1.1.0

func NewState() *State

NewState creates a default state object with a fresh channel for state changes.

func (*State) IsRunning

func (s *State) IsRunning() bool

IsRunning returns whether the running flag is set. Used by Container to check whether a container is running.

func (*State) StateString added in v1.3.0

func (s *State) StateString() string

StateString returns a single string to describe state

func (*State) String

func (s *State) String() string

String returns a human-readable description of the state

func (*State) WaitStop added in v1.1.0

func (s *State) WaitStop(timeout time.Duration) (int, error)

WaitStop waits until state is stopped. If state already stopped it returns immediately. If you want wait forever you must supply negative timeout. Returns exit code, that was passed to setStoppedLocking

Directories

Path Synopsis
lxc
vfs
zfs
Package logger defines interfaces that logger drivers implement to log messages.
Package logger defines interfaces that logger drivers implement to log messages.
awslogs
Package awslogs provides the logdriver for forwarding container logs to Amazon CloudWatch Logs
Package awslogs provides the logdriver for forwarding container logs to Amazon CloudWatch Logs
fluentd
Package fluentd provides the log driver for forwarding server logs to fluentd endpoints.
Package fluentd provides the log driver for forwarding server logs to fluentd endpoints.
gelf
Package gelf provides the log driver for forwarding server logs to endpoints that support the Graylog Extended Log Format.
Package gelf provides the log driver for forwarding server logs to endpoints that support the Graylog Extended Log Format.
journald
Package journald provides the log driver for forwarding server logs to endpoints that receive the systemd format.
Package journald provides the log driver for forwarding server logs to endpoints that receive the systemd format.
jsonfilelog
Package jsonfilelog provides the default Logger implementation for Docker logging.
Package jsonfilelog provides the default Logger implementation for Docker logging.
syslog
Package syslog provides the logdriver for forwarding server logs to syslog endpoints.
Package syslog provides the logdriver for forwarding server logs to syslog endpoints.

Jump to

Keyboard shortcuts

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