docker – github.com/docker/docker Index | Files | Directories

package docker

import "github.com/docker/docker"

Index

Constants

const DEFAULTTAG = "latest"
const (
	DisableNetworkBridge = "none"
)
const MaxImageDepth = 127

Set the max depth to the aufs default that most kernels are compiled with For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk

Variables

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.")
)
var (
	ErrDockerfileEmpty = errors.New("Dockerfile cannot be empty")
)
var ErrImageReferenced = errors.New("Image referenced by a repository")

Functions

func GenerateID

func GenerateID() string

func GetDefaultNetworkMtu

func GetDefaultNetworkMtu() int

func StoreImage

func StoreImage(img *Image, jsonData []byte, layerData archive.ArchiveReader, root, layer string) error

func ValidateID

func ValidateID(id string) error

Types

type BindMap

type BindMap struct {
	SrcPath string
	DstPath string
	Mode    string
}

type BuildFile

type BuildFile interface {
	Build(io.Reader) (string, error)
	CmdFrom(string) error
	CmdRun(string) error
}

func NewBuildFile

func NewBuildFile(srv *Server, outStream, errStream io.Writer, verbose, utilizeCache, rm bool, outOld io.Writer, sf *utils.StreamFormatter, auth *auth.AuthConfig, authConfigFile *auth.ConfigFile) BuildFile

type Change

type Change struct {
	archive.Change
}

type Container

type Container struct {
	sync.Mutex

	ID string

	Created time.Time

	Path string
	Args []string

	Config *runconfig.Config
	State  State
	Image  string

	NetworkSettings *NetworkSettings

	ResolvConfPath string
	HostnamePath   string
	HostsPath      string
	Name           string
	Driver         string

	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
	// contains filtered or unexported fields
}

func (*Container) Attach

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

func (*Container) BasefsPath

func (container *Container) BasefsPath() string

This is the stand-alone version of the root fs, without any additional mounts. This directory is usable whenever the container is mounted (and not unmounted)

func (*Container) Changes

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

func (*Container) Copy

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

func (*Container) EnvConfigPath

func (container *Container) EnvConfigPath() (string, 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) GetImage

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

func (*Container) GetPtyMaster

func (container *Container) GetPtyMaster() (*os.File, error)

func (*Container) GetSize

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

GetSize, return real size, virtual size

func (*Container) Inject

func (container *Container) Inject(file io.Reader, pth string) error

Inject the io.Reader at the given path. Note: do not close the reader

func (*Container) Kill

func (container *Container) Kill() error

func (*Container) Mount

func (container *Container) Mount() error

func (*Container) Output

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

func (*Container) ReadLog

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

func (*Container) Resize

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

func (*Container) Restart

func (container *Container) Restart(seconds int) 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) Start

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

func (*Container) StderrPipe

func (container *Container) StderrPipe() (io.ReadCloser, error)

func (*Container) StdinPipe

func (container *Container) StdinPipe() (io.WriteCloser, error)

func (*Container) StdoutPipe

func (container *Container) StdoutPipe() (io.ReadCloser, error)

func (*Container) Stop

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

func (*Container) ToDisk

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

func (*Container) Unmount

func (container *Container) Unmount() error

func (*Container) Wait

func (container *Container) Wait() int

Wait blocks until the container stops running, then returns its exit code.

func (*Container) WaitTimeout

func (container *Container) WaitTimeout(timeout time.Duration) error

func (*Container) When

func (container *Container) When() time.Time

type DaemonConfig

type DaemonConfig struct {
	Pidfile                     string
	Root                        string
	AutoRestart                 bool
	Dns                         []string
	EnableIptables              bool
	EnableIpForward             bool
	DefaultIp                   net.IP
	BridgeIface                 string
	BridgeIP                    string
	InterContainerCommunication bool
	GraphDriver                 string
	Mtu                         int
	DisableNetwork              bool
}

FIXME: separate runtime configuration from http api configuration

func DaemonConfigFromJob

func DaemonConfigFromJob(job *engine.Job) *DaemonConfig

ConfigFromJob creates and returns a new DaemonConfig object by parsing the contents of a job's environment.

type Graph

type Graph struct {
	Root string
	// contains filtered or unexported fields
}

A Graph is a store for versioned filesystem images and the relationship between them.

func NewGraph

func NewGraph(root string, driver graphdriver.Driver) (*Graph, error)

NewGraph instantiates a new graph at the given root path in the filesystem. `root` will be created if it doesn't exist.

func (*Graph) ByParent

func (graph *Graph) ByParent() (map[string][]*Image, error)

ByParent returns a lookup table of images by their parent. If an image of id ID has 3 children images, then the value for key ID will be a list of 3 images. If an image has no children, it will not have an entry in the table.

func (*Graph) Create

func (graph *Graph) Create(layerData archive.ArchiveReader, container *Container, comment, author string, config *runconfig.Config) (*Image, error)

Create creates a new image and registers it in the graph.

func (*Graph) Delete

func (graph *Graph) Delete(name string) error

Delete atomically removes an image from the graph.

func (*Graph) Driver

func (graph *Graph) Driver() graphdriver.Driver

func (*Graph) Exists

func (graph *Graph) Exists(id string) bool

Exists returns true if an image is registered at the given id. If the image doesn't exist or if an error is encountered, false is returned.

func (*Graph) Get

func (graph *Graph) Get(name string) (*Image, error)

Get returns the image with the given id, or an error if the image doesn't exist.

func (*Graph) Heads

func (graph *Graph) Heads() (map[string]*Image, error)

Heads returns all heads in the graph, keyed by id. A head is an image which is not the parent of another image in the graph.

func (*Graph) IsNotExist

func (graph *Graph) IsNotExist(err error) bool

FIXME: Implement error subclass instead of looking at the error text Note: This is the way golang implements os.IsNotExists on Plan9

func (*Graph) Map

func (graph *Graph) Map() (map[string]*Image, error)

Map returns a list of all images in the graph, addressable by ID.

func (*Graph) Mktemp

func (graph *Graph) Mktemp(id string) (string, error)

Mktemp creates a temporary sub-directory inside the graph's filesystem.

func (*Graph) Register

func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, img *Image) (err error)

Register imports a pre-existing image into the graph. FIXME: pass img as first argument

func (*Graph) TempLayerArchive

func (graph *Graph) TempLayerArchive(id string, compression archive.Compression, sf *utils.StreamFormatter, output io.Writer) (*archive.TempArchive, error)

TempLayerArchive creates a temporary archive of the given image's filesystem layer.

The archive is stored on disk and will be automatically deleted as soon as has been read.
If output is not nil, a human-readable progress bar will be written to it.
FIXME: does this belong in Graph? How about MktempFile, let the caller use it for archives?

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) Swap

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

type Image

type Image struct {
	ID              string            `json:"id"`
	Parent          string            `json:"parent,omitempty"`
	Comment         string            `json:"comment,omitempty"`
	Created         time.Time         `json:"created"`
	Container       string            `json:"container,omitempty"`
	ContainerConfig runconfig.Config  `json:"container_config,omitempty"`
	DockerVersion   string            `json:"docker_version,omitempty"`
	Author          string            `json:"author,omitempty"`
	Config          *runconfig.Config `json:"config,omitempty"`
	Architecture    string            `json:"architecture,omitempty"`
	OS              string            `json:"os,omitempty"`

	Size int64
	// contains filtered or unexported fields
}

func LoadImage

func LoadImage(root string) (*Image, error)

func NewImgJSON

func NewImgJSON(src []byte) (*Image, error)

Build an Image object from raw json data

func (*Image) Depth

func (img *Image) Depth() (int, error)

Depth returns the number of parents for a current image

func (*Image) GetParent

func (img *Image) GetParent() (*Image, error)

func (*Image) History

func (img *Image) History() ([]*Image, error)

Image includes convenience proxy functions to its graph These functions will return an error if the image is not registered (ie. if image.graph == nil)

func (*Image) SaveSize

func (img *Image) SaveSize(root string) error

SaveSize stores the current `size` value of `img` in the directory `root`.

func (*Image) TarLayer

func (img *Image) TarLayer() (arch archive.Archive, err error)

TarLayer returns a tar archive of the image's filesystem layer.

func (*Image) WalkHistory

func (img *Image) WalkHistory(handler func(*Image) error) (err error)

type NetworkSettings

type NetworkSettings struct {
	IPAddress   string
	IPPrefixLen int
	Gateway     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 Repository

type Repository map[string]string

type Runtime

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

func NewRuntime

func NewRuntime(config *DaemonConfig, eng *engine.Engine) (*Runtime, error)

FIXME: harmonize with NewGraph()

func NewRuntimeFromDirectory

func NewRuntimeFromDirectory(config *DaemonConfig, eng *engine.Engine) (*Runtime, error)

func (*Runtime) Changes

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

func (*Runtime) Children

func (runtime *Runtime) Children(name string) (map[string]*Container, error)

func (*Runtime) Close

func (runtime *Runtime) Close() error

func (*Runtime) Commit

func (runtime *Runtime) Commit(container *Container, repository, tag, comment, author string, config *runconfig.Config) (*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 (*Runtime) Create

func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Container, []string, error)

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

func (*Runtime) Destroy

func (runtime *Runtime) Destroy(container *Container) error

Destroy unregisters a container from the runtime and cleanly removes its contents from the filesystem.

func (*Runtime) Diff

func (runtime *Runtime) Diff(container *Container) (archive.Archive, error)

func (*Runtime) Exists

func (runtime *Runtime) Exists(id string) bool

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

func (*Runtime) Get

func (runtime *Runtime) Get(name string) *Container

Get looks for a container by the specified ID or name, and returns it. If the container is not found, or if an error occurs, nil is returned.

func (*Runtime) GetByName

func (runtime *Runtime) GetByName(name string) (*Container, error)

func (*Runtime) Graph

func (runtime *Runtime) Graph() *Graph

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

func (*Runtime) Kill

func (runtime *Runtime) Kill(c *Container, sig int) error

func (*Runtime) List

func (runtime *Runtime) List() []*Container

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

func (*Runtime) LogToDisk

func (runtime *Runtime) LogToDisk(src *utils.WriteBroadcaster, dst, stream string) error

func (*Runtime) Mount

func (runtime *Runtime) Mount(container *Container) error

func (*Runtime) Nuke

func (runtime *Runtime) 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 runtime!

func (*Runtime) Register

func (runtime *Runtime) Register(container *Container) error

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

func (runtime *Runtime) RegisterLink(parent, child *Container, alias string) error

func (*Runtime) RestoreCommand

func (runtime *Runtime) RestoreCommand(c *Container) error

func (*Runtime) Run

func (runtime *Runtime) Run(c *Container, startCallback execdriver.StartCallback) (int, error)

func (*Runtime) Unmount

func (runtime *Runtime) Unmount(container *Container) error

type Server

type Server struct {
	sync.RWMutex

	Eng *engine.Engine
	// contains filtered or unexported fields
}

func NewServer

func NewServer(eng *engine.Engine, config *DaemonConfig) (*Server, error)

func (*Server) AddEvent

func (srv *Server) AddEvent(jm utils.JSONMessage)

func (*Server) Auth

func (srv *Server) Auth(job *engine.Job) engine.Status

func (*Server) Build

func (srv *Server) Build(job *engine.Job) engine.Status

func (*Server) Close

func (srv *Server) Close() error

func (*Server) ContainerAttach

func (srv *Server) ContainerAttach(job *engine.Job) engine.Status

func (*Server) ContainerChanges

func (srv *Server) ContainerChanges(job *engine.Job) engine.Status

func (*Server) ContainerCommit

func (srv *Server) ContainerCommit(job *engine.Job) engine.Status

func (*Server) ContainerCopy

func (srv *Server) ContainerCopy(job *engine.Job) engine.Status

func (*Server) ContainerCreate

func (srv *Server) ContainerCreate(job *engine.Job) engine.Status

func (*Server) ContainerDestroy

func (srv *Server) ContainerDestroy(job *engine.Job) engine.Status

func (*Server) ContainerExport

func (srv *Server) ContainerExport(job *engine.Job) engine.Status

func (*Server) ContainerInspect

func (srv *Server) ContainerInspect(name string) (*Container, error)

func (*Server) ContainerKill

func (srv *Server) 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 (*Server) ContainerResize

func (srv *Server) ContainerResize(job *engine.Job) engine.Status

func (*Server) ContainerRestart

func (srv *Server) ContainerRestart(job *engine.Job) engine.Status

func (*Server) ContainerStart

func (srv *Server) ContainerStart(job *engine.Job) engine.Status

func (*Server) ContainerStop

func (srv *Server) ContainerStop(job *engine.Job) engine.Status

func (*Server) ContainerTop

func (srv *Server) ContainerTop(job *engine.Job) engine.Status

func (*Server) ContainerWait

func (srv *Server) ContainerWait(job *engine.Job) engine.Status

func (*Server) Containers

func (srv *Server) Containers(job *engine.Job) engine.Status

func (*Server) DeleteImage

func (srv *Server) DeleteImage(name string, autoPrune bool) (*engine.Table, error)

func (*Server) DockerInfo

func (srv *Server) DockerInfo(job *engine.Job) engine.Status

func (*Server) Events

func (srv *Server) Events(job *engine.Job) engine.Status

func (*Server) GetEvents

func (srv *Server) GetEvents() []utils.JSONMessage

func (*Server) HTTPRequestFactory

func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory

func (*Server) ImageDelete

func (srv *Server) ImageDelete(job *engine.Job) engine.Status

func (*Server) ImageExport

func (srv *Server) ImageExport(job *engine.Job) engine.Status

ImageExport exports all images with the given tag. All versions containing the same tag are exported. The resulting output is an uncompressed tar ball. name is the set of tags to export. out is the writer where the images are written to.

func (*Server) ImageGetCached

func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*Image, error)

func (*Server) ImageHistory

func (srv *Server) ImageHistory(job *engine.Job) engine.Status

func (*Server) ImageImport

func (srv *Server) ImageImport(job *engine.Job) engine.Status

func (*Server) ImageInsert

func (srv *Server) ImageInsert(job *engine.Job) engine.Status

func (*Server) ImageInspect

func (srv *Server) ImageInspect(name string) (*Image, error)

func (*Server) ImageLoad

func (srv *Server) ImageLoad(job *engine.Job) engine.Status

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

func (*Server) ImagePull

func (srv *Server) ImagePull(job *engine.Job) engine.Status

func (*Server) ImagePush

func (srv *Server) ImagePush(job *engine.Job) engine.Status

FIXME: Allow to interrupt current push when new push of same image is done.

func (*Server) ImageTag

func (srv *Server) ImageTag(job *engine.Job) engine.Status

func (*Server) Images

func (srv *Server) Images(job *engine.Job) engine.Status

func (*Server) ImagesSearch

func (srv *Server) ImagesSearch(job *engine.Job) engine.Status

func (*Server) ImagesViz

func (srv *Server) ImagesViz(job *engine.Job) engine.Status

func (*Server) JobInspect

func (srv *Server) JobInspect(job *engine.Job) engine.Status

func (*Server) LogEvent

func (srv *Server) LogEvent(action, id, from string) *utils.JSONMessage
func (srv *Server) RegisterLinks(container *Container, hostConfig *runconfig.HostConfig) error

type State

type State struct {
	sync.RWMutex
	Running    bool
	Pid        int
	ExitCode   int
	StartedAt  time.Time
	FinishedAt time.Time
	Ghost      bool
}

func (*State) GetExitCode

func (s *State) GetExitCode() int

func (*State) IsGhost

func (s *State) IsGhost() bool

func (*State) IsRunning

func (s *State) IsRunning() bool

func (*State) SetGhost

func (s *State) SetGhost(val bool)

func (*State) SetRunning

func (s *State) SetRunning(pid int)

func (*State) SetStopped

func (s *State) SetStopped(exitCode int)

func (*State) String

func (s *State) String() string

String returns a human-readable description of the state

type StderrFormater

type StderrFormater struct {
	io.Writer
	*utils.StreamFormatter
}

func (*StderrFormater) Write

func (sf *StderrFormater) Write(buf []byte) (int, error)

type StdoutFormater

type StdoutFormater struct {
	io.Writer
	*utils.StreamFormatter
}

func (*StdoutFormater) Write

func (sf *StdoutFormater) Write(buf []byte) (int, error)

type TagStore

type TagStore struct {
	Repositories map[string]Repository
	// contains filtered or unexported fields
}

func NewTagStore

func NewTagStore(path string, graph *Graph) (*TagStore, error)

func (*TagStore) ByID

func (store *TagStore) ByID() map[string][]string

Return a reverse-lookup table of all the names which refer to each image Eg. {"43b5f19b10584": {"base:latest", "base:v1"}}

func (*TagStore) Delete

func (store *TagStore) Delete(repoName, tag string) (bool, error)

func (*TagStore) DeleteAll

func (store *TagStore) DeleteAll(id string) error

func (*TagStore) Get

func (store *TagStore) Get(repoName string) (Repository, error)

func (*TagStore) GetImage

func (store *TagStore) GetImage(repoName, tagOrID string) (*Image, error)

func (*TagStore) ImageName

func (store *TagStore) ImageName(id string) string

func (*TagStore) LookupImage

func (store *TagStore) LookupImage(name string) (*Image, error)

func (*TagStore) Reload

func (store *TagStore) Reload() error

func (*TagStore) Save

func (store *TagStore) Save() error

func (*TagStore) Set

func (store *TagStore) Set(repoName, tag, imageName string, force bool) error

Source Files

buildfile.go config.go container.go graph.go image.go runtime.go server.go sorter.go state.go tags.go utils.go version.go volumes.go

Directories

PathSynopsis
api
archive
auth
contrib
contrib/docker-device-tool
contrib/host-integration
docker
dockerinit
dockerversion
engine
execdriver
execdriver/chroot
execdriver/lxc
graphdriver
graphdriver/aufs
graphdriver/btrfs
graphdriver/devmapper
graphdriver/vfs
integration
links
nat
networkdriver
networkdriver/ipallocator
networkdriver/lxc
networkdriver/portallocator
networkdriver/portmapper
pkg
pkg/cgroups
pkg/collections
pkg/graphdb
pkg/iptables
pkg/listenbufferPackage to allow go applications to immediately start listening on a socket, unix, tcp, udp but hold connections until the application has booted and is ready to accept them
pkg/mflagPackage flag implements command-line flag parsing.
pkg/mflag/example
pkg/mount
pkg/namesgenerator
pkg/netlinkPacket netlink provide access to low level Netlink sockets and messages.
pkg/opts
pkg/proxy
pkg/sysinfo
pkg/systemd
pkg/systemd/activation
pkg/term
pkg/user
registry
runconfig
sysinit
utils
Version
v0.8.1
Published
Feb 18, 2014
Platform
js/wasm
Imports
52 packages
Last checked
1 hour ago

Tools for package owners.