daemon

package
v1.6.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2015 License: Apache-2.0 Imports: 84 Imported by: 0

README

This directory contains code pertaining to running containers and storing images

Code pertaining to running containers:

  • execdriver
  • networkdriver

Code pertaining to storing images:

  • graphdriver

Documentation

Index

Constants

View Source
const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Variables

View Source
var (
	ErrNotATTY               = errors.New("The PTY is not a file")
	ErrNoTTY                 = errors.New("No PTY found")
	ErrContainerStart        = errors.New("The container failed to start. Unknown error")
	ErrContainerStartTimeout = errors.New("The container failed to start due to timed out.")
)

Functions

func GetFullContainerName

func GetFullContainerName(name string) (string, error)

Types

type Config added in v1.2.0

type Config struct {
	Pidfile                     string
	Root                        string
	AutoRestart                 bool
	Dns                         []string
	DnsSearch                   []string
	EnableIPv6                  bool
	EnableIptables              bool
	EnableIpForward             bool
	EnableIpMasq                bool
	DefaultIp                   net.IP
	BridgeIface                 string
	BridgeIP                    string
	FixedCIDR                   string
	FixedCIDRv6                 string
	InterContainerCommunication bool
	GraphDriver                 string
	GraphOptions                []string
	ExecDriver                  string
	Mtu                         int
	SocketGroup                 string
	EnableCors                  bool
	CorsHeaders                 string
	DisableNetwork              bool
	EnableSelinuxSupport        bool
	Context                     map[string][]string
	TrustKeyPath                string
	Labels                      []string
	Ulimits                     map[string]*ulimit.Ulimit
	LogConfig                   runconfig.LogConfig
}

Config define 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 -d -e lxc` FIXME: separate runtime configuration from http api configuration

func (*Config) InstallFlags added in v1.2.0

func (config *Config) InstallFlags()

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 {
	*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 *NetworkSettings

	ResolvConfPath string
	HostnamePath   string
	HostsPath      string
	LogPath        string
	Name           string
	Driver         string
	ExecDriver     string

	StreamConfig

	MountLabel, ProcessLabel string
	AppArmorProfile          string
	RestartCount             int
	UpdateDns                bool

	// Maps container paths to volume paths.  The key in this is the path to which
	// the volume is being mounted inside the container.  Value is the path of the
	// volume on disk
	Volumes map[string]string
	// Store rw/ro in a separate structure to preserve reverse-compatibility on-disk.
	// Easier than migrating older container configs :)
	VolumesRW map[string]bool

	AppliedVolumesFrom map[string]struct{}
	// contains filtered or unexported fields
}

func (*Container) AllocateNetwork added in v1.3.0

func (container *Container) AllocateNetwork() error

func (*Container) Changes

func (container *Container) Changes() ([]archive.Change, error)

func (*Container) Copy

func (container *Container) Copy(resource string) (io.ReadCloser, error)
func (container *Container) DisableLink(name string)

func (*Container) Exec added in v1.3.0

func (container *Container) Exec(execConfig *execConfig) error

func (*Container) Export

func (container *Container) Export() (archive.Archive, error)

func (*Container) ExportRw

func (container *Container) ExportRw() (archive.Archive, error)

func (*Container) Exposes

func (container *Container) Exposes(p nat.Port) bool

Returns true if the container exposes a certain port

func (*Container) FromDisk

func (container *Container) FromDisk() error

func (*Container) GetExecIDs added in v1.5.0

func (container *Container) GetExecIDs() []string

func (*Container) GetImage

func (container *Container) GetImage() (*image.Image, error)

func (*Container) GetMountLabel

func (container *Container) GetMountLabel() string

func (*Container) GetProcessLabel

func (container *Container) GetProcessLabel() string

func (*Container) GetPtyMaster

func (container *Container) GetPtyMaster() (libcontainer.Console, error)

func (*Container) GetSize

func (container *Container) GetSize() (int64, int64)

GetSize, return real size, virtual size

func (*Container) HostConfig

func (container *Container) HostConfig() *runconfig.HostConfig

func (*Container) Kill

func (container *Container) Kill() error

func (*Container) KillSig

func (container *Container) KillSig(sig int) error

func (*Container) LogDriverType added in v1.6.0

func (c *Container) LogDriverType() string

func (*Container) LogEvent added in v1.2.0

func (container *Container) LogEvent(action string)

func (*Container) Mount

func (container *Container) Mount() error

func (*Container) Output

func (container *Container) Output() (output []byte, err error)

func (*Container) Pause added in v0.12.0

func (container *Container) Pause() error

func (*Container) ReadLog

func (container *Container) ReadLog(name string) (io.Reader, error)

func (*Container) ReleaseNetwork added in v1.3.0

func (container *Container) ReleaseNetwork()

func (*Container) Resize

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

func (*Container) Restart

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

func (*Container) RestoreNetwork added in v1.3.0

func (container *Container) RestoreNetwork() error

func (*Container) RootfsPath

func (container *Container) RootfsPath() string

This method must be exported to be used from the lxc template This directory is only usable when the container is running

func (*Container) Run

func (container *Container) Run() error

func (*Container) SetHostConfig

func (container *Container) SetHostConfig(hostConfig *runconfig.HostConfig)

func (*Container) Start

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

func (*Container) Stats added in v1.5.0

func (container *Container) Stats() (*execdriver.ResourceStats, error)

func (*Container) Stop

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

func (*Container) ToDisk

func (container *Container) ToDisk() error

func (*Container) Unmount

func (container *Container) Unmount() error

func (*Container) Unpause added in v0.12.0

func (container *Container) Unpause() error

func (*Container) VolumeMounts added in v1.3.0

func (container *Container) VolumeMounts() map[string]*Mount

func (*Container) VolumePaths added in v1.3.0

func (container *Container) VolumePaths() map[string]struct{}

func (*Container) WriteHostConfig

func (container *Container) WriteHostConfig() error

type Daemon

type Daemon struct {
	ID string
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(config *Config, eng *engine.Engine) (*Daemon, error)

FIXME: harmonize with NewGraph()

func NewDaemonFromDirectory

func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)

func (*Daemon) Attach

func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) chan error

func (*Daemon) Changes

func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error)

func (*Daemon) Children

func (daemon *Daemon) Children(name string) (map[string]*Container, error)

func (*Daemon) CmdInfo added in v1.2.0

func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status

func (*Daemon) Commit

func (daemon *Daemon) Commit(container *Container, repository, tag, comment, author string, pause bool, config *runconfig.Config) (*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) Config

func (daemon *Daemon) Config() *Config

func (*Daemon) ContainerAttach added in v1.2.0

func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status

func (*Daemon) ContainerChanges added in v1.2.0

func (daemon *Daemon) ContainerChanges(job *engine.Job) engine.Status

func (*Daemon) ContainerCommit added in v1.2.0

func (daemon *Daemon) ContainerCommit(job *engine.Job) engine.Status

func (*Daemon) ContainerCopy added in v1.2.0

func (daemon *Daemon) ContainerCopy(job *engine.Job) engine.Status

func (*Daemon) ContainerCreate added in v1.2.0

func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status

func (*Daemon) ContainerExecCreate added in v1.3.0

func (d *Daemon) ContainerExecCreate(job *engine.Job) engine.Status

func (*Daemon) ContainerExecInspect added in v1.4.0

func (daemon *Daemon) ContainerExecInspect(job *engine.Job) engine.Status

func (*Daemon) ContainerExecResize added in v1.3.0

func (daemon *Daemon) ContainerExecResize(job *engine.Job) engine.Status

func (*Daemon) ContainerExecStart added in v1.3.0

func (d *Daemon) ContainerExecStart(job *engine.Job) engine.Status

func (*Daemon) ContainerExport added in v1.2.0

func (daemon *Daemon) ContainerExport(job *engine.Job) engine.Status

func (*Daemon) ContainerGraph

func (daemon *Daemon) ContainerGraph() *graphdb.Database

func (*Daemon) ContainerInspect added in v0.12.0

func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status

func (*Daemon) ContainerKill added in v1.2.0

func (daemon *Daemon) ContainerKill(job *engine.Job) engine.Status

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(job *engine.Job) engine.Status

func (*Daemon) ContainerPause added in v1.2.0

func (daemon *Daemon) ContainerPause(job *engine.Job) engine.Status

func (*Daemon) ContainerRename added in v1.5.0

func (daemon *Daemon) ContainerRename(job *engine.Job) engine.Status

func (*Daemon) ContainerResize added in v1.2.0

func (daemon *Daemon) ContainerResize(job *engine.Job) engine.Status

func (*Daemon) ContainerRestart added in v1.2.0

func (daemon *Daemon) ContainerRestart(job *engine.Job) engine.Status

func (*Daemon) ContainerRm added in v1.3.0

func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status

func (*Daemon) ContainerStart added in v1.2.0

func (daemon *Daemon) ContainerStart(job *engine.Job) engine.Status

func (*Daemon) ContainerStats added in v1.5.0

func (daemon *Daemon) ContainerStats(job *engine.Job) engine.Status

func (*Daemon) ContainerStop added in v1.2.0

func (daemon *Daemon) ContainerStop(job *engine.Job) engine.Status

func (*Daemon) ContainerTop added in v1.2.0

func (daemon *Daemon) ContainerTop(job *engine.Job) engine.Status

func (*Daemon) ContainerUnpause added in v1.2.0

func (daemon *Daemon) ContainerUnpause(job *engine.Job) engine.Status

func (*Daemon) ContainerWait added in v1.2.0

func (daemon *Daemon) ContainerWait(job *engine.Job) engine.Status

func (*Daemon) Containers added in v1.2.0

func (daemon *Daemon) Containers(job *engine.Job) engine.Status

func (*Daemon) Create

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

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

func (*Daemon) DeleteImage added in v1.2.0

func (daemon *Daemon) DeleteImage(eng *engine.Engine, name string, imgs *engine.Table, first, force, noprune bool) error

FIXME: make this private and use the job instead

func (*Daemon) DeleteVolumes added in v1.3.0

func (daemon *Daemon) DeleteVolumes(volumeIDs map[string]struct{})

func (*Daemon) Diff

func (daemon *Daemon) Diff(container *Container) (archive.Archive, error)

func (*Daemon) Exec added in v1.3.0

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

func (*Daemon) ExecutionDriver

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

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) ForceRm added in v1.6.0

func (daemon *Daemon) ForceRm(container *Container) (err error)

func (*Daemon) GenerateSecurityOpt added in v1.4.0

func (daemon *Daemon) GenerateSecurityOpt(ipcMode runconfig.IpcMode, pidMode runconfig.PidMode) ([]string, error)

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)

func (*Daemon) Graph

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

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

func (*Daemon) ImageDelete added in v1.2.0

func (daemon *Daemon) ImageDelete(job *engine.Job) engine.Status

func (*Daemon) ImageGetCached added in v1.2.0

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

func (*Daemon) Install added in v0.12.0

func (daemon *Daemon) Install(eng *engine.Engine) error

Install installs daemon capabilities to eng.

func (*Daemon) Kill

func (daemon *Daemon) Kill(c *Container, sig int) error

func (*Daemon) List

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

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

func (*Daemon) LogToDisk

func (daemon *Daemon) LogToDisk(src *broadcastwriter.BroadcastWriter, dst, stream string) error

func (*Daemon) Mount

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

func (*Daemon) Nuke

func (daemon *Daemon) Nuke() error

Nuke kills all containers then removes all content from the content root, including images, volumes and container filesystems. Again: this will remove your entire docker daemon! FIXME: this is deprecated, and only used in legacy tests. Please remove.

func (*Daemon) Parents added in v1.3.0

func (daemon *Daemon) Parents(name string) ([]string, error)

func (*Daemon) Pause added in v0.12.0

func (daemon *Daemon) Pause(c *Container) error

func (*Daemon) Register

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

Register makes a container object usable by the daemon as <container.ID> This is a wrapper for register

func (daemon *Daemon) RegisterLink(parent, child *Container, alias string) error
func (daemon *Daemon) RegisterLinks(container *Container, hostConfig *runconfig.HostConfig) error

func (*Daemon) Repositories

func (daemon *Daemon) Repositories() *graph.TagStore

func (*Daemon) Rm added in v1.6.0

func (daemon *Daemon) Rm(container *Container) (err error)

func (*Daemon) Run

func (daemon *Daemon) Run(c *Container, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (execdriver.ExitStatus, error)

func (*Daemon) Stats added in v1.5.0

func (daemon *Daemon) Stats(c *Container) (*execdriver.ResourceStats, error)

func (*Daemon) SubscribeToContainerStats added in v1.5.0

func (daemon *Daemon) SubscribeToContainerStats(name string) (chan interface{}, error)

func (*Daemon) SystemConfig

func (daemon *Daemon) SystemConfig() *sysinfo.SysInfo

func (*Daemon) SystemInitPath

func (daemon *Daemon) SystemInitPath() string

func (*Daemon) Unmount

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

func (*Daemon) Unpause added in v0.12.0

func (daemon *Daemon) Unpause(c *Container) error

func (*Daemon) UnsubscribeToContainerStats added in v1.5.0

func (daemon *Daemon) UnsubscribeToContainerStats(name string, ch chan interface{}) error

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)

func (*History) Len

func (history *History) Len() int

func (*History) Less

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

func (*History) Sort added in v0.12.0

func (history *History) Sort()

func (*History) Swap

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

type Mount added in v1.3.0

type Mount struct {
	MountToPath string

	Writable bool
	// contains filtered or unexported fields
}

func (*Mount) Export added in v1.4.0

func (mnt *Mount) Export(resource string) (io.ReadCloser, error)

type NetworkSettings

type NetworkSettings struct {
	IPAddress              string
	IPPrefixLen            int
	MacAddress             string
	LinkLocalIPv6Address   string
	LinkLocalIPv6PrefixLen int
	GlobalIPv6Address      string
	GlobalIPv6PrefixLen    int
	Gateway                string
	IPv6Gateway            string
	Bridge                 string
	PortMapping            map[string]PortMapping // Deprecated
	Ports                  nat.PortMap
}

func (*NetworkSettings) PortMappingAPI

func (settings *NetworkSettings) PortMappingAPI() *engine.Table

type PortMapping

type PortMapping map[string]string // Deprecated

FIXME: move deprecated port stuff to nat to clean up the core.

type State

type State struct {
	sync.Mutex
	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
}

func NewState added in v1.1.0

func NewState() *State

func (*State) GetExitCode

func (s *State) GetExitCode() int

func (*State) GetPid added in v1.1.0

func (s *State) GetPid() int

func (*State) IsPaused added in v0.12.0

func (s *State) IsPaused() bool

func (*State) IsRestarting added in v1.2.0

func (s *State) IsRestarting() bool

func (*State) IsRunning

func (s *State) IsRunning() bool

func (*State) ResetRemovalInProgress added in v1.6.0

func (s *State) ResetRemovalInProgress()

func (*State) SetDead added in v1.6.0

func (s *State) SetDead()

func (*State) SetPaused added in v0.12.0

func (s *State) SetPaused()

func (*State) SetRemovalInProgress added in v1.6.0

func (s *State) SetRemovalInProgress() error

func (*State) SetRestarting added in v1.2.0

func (s *State) SetRestarting(exitStatus *execdriver.ExitStatus)

SetRestarting is when docker hanldes the auto restart of containers when they are in the middle of a stop and being restarted again

func (*State) SetRunning

func (s *State) SetRunning(pid int)

func (*State) SetStopped

func (s *State) SetStopped(exitStatus *execdriver.ExitStatus)

func (*State) SetUnpaused added in v0.12.0

func (s *State) SetUnpaused()

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) WaitRunning added in v1.1.0

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

WaitRunning waits until state is running. If state already running it returns immediately. If you want wait forever you must supply negative timeout. Returns pid, that was passed to SetRunning

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 SetStopped

type StreamConfig added in v1.3.0

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

func (*StreamConfig) StderrLogPipe added in v1.3.0

func (streamConfig *StreamConfig) StderrLogPipe() io.ReadCloser

func (*StreamConfig) StderrPipe added in v1.3.0

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

func (*StreamConfig) StdinPipe added in v1.3.0

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

func (*StreamConfig) StdoutLogPipe added in v1.3.0

func (streamConfig *StreamConfig) StdoutLogPipe() io.ReadCloser

func (*StreamConfig) StdoutPipe added in v1.3.0

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

Jump to

Keyboard shortcuts

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