package container
import "github.com/docker/docker/container"
Index ¶
- func AttachStreams(ctx context.Context, streamConfig *runconfig.StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer, keys []byte) chan error
- func GetSandboxPortMapInfo(sb libnetwork.Sandbox) nat.PortMap
- func IsValidStateString(s string) bool
- type CommonContainer
- type DetachError
- type Health
- func (s *Health) CloseMonitorChannel()
- func (s *Health) OpenMonitorChannel() chan struct{}
- func (s *Health) String() string
- type History
- func (history *History) Len() int
- func (history *History) Less(i, j int) bool
- func (history *History) Swap(i, j int)
- type Mount
- type State
- func NewState() *State
- func (s *State) Error() string
- func (s *State) ExitCode() int
- func (s *State) GetPID() int
- func (s *State) IsPaused() bool
- func (s *State) IsRestarting() bool
- func (s *State) IsRunning() bool
- func (s *State) ResetRemovalInProgress()
- func (s *State) SetDead()
- func (s *State) SetError(err error)
- func (s *State) SetExitCode(ec int)
- func (s *State) SetRemovalInProgress() bool
- func (s *State) SetRestarting(exitStatus *ExitStatus)
- func (s *State) SetRestartingLocking(exitStatus *ExitStatus)
- func (s *State) SetRunning(pid int, initial bool)
- func (s *State) SetStopped(exitStatus *ExitStatus)
- func (s *State) SetStoppedLocking(exitStatus *ExitStatus)
- func (s *State) StateString() string
- func (s *State) String() string
- func (s *State) WaitStop(timeout time.Duration) (int, error)
- func (s *State) WaitWithContext(ctx context.Context) error
- type Store
- type StoreFilter
- type StoreReducer
Functions ¶
func AttachStreams ¶
func AttachStreams(ctx context.Context, streamConfig *runconfig.StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer, keys []byte) chan error
AttachStreams connects streams to a TTY. Used by exec too. Should this move somewhere else?
func GetSandboxPortMapInfo ¶
func GetSandboxPortMapInfo(sb libnetwork.Sandbox) nat.PortMap
GetSandboxPortMapInfo retrieves the current port-mapping programmed for the given sandbox
func IsValidStateString ¶
IsValidStateString checks if the provided string is a valid container state or not.
Types ¶
type CommonContainer ¶
type CommonContainer struct { *runconfig.StreamConfig // embed for Container to support states directly. *State `json:"State"` // Needed for remote api version <= 1.11 Root string `json:"-"` // Path to the "home" of the container, including metadata. BaseFS string `json:"-"` // Path to the graphdriver mountpoint RWLayer layer.RWLayer `json:"-"` ID string Created time.Time Managed bool Path string Args []string Config *containertypes.Config ImageID image.ID `json:"Image"` NetworkSettings *network.Settings LogPath string Name string Driver 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 MountPoints map[string]*volume.MountPoint HostConfig *containertypes.HostConfig `json:"-"` // do not serialize the host config in the json, otherwise we'll make the container unportable ExecCommands *exec.Store `json:"-"` // logDriver for closing LogDriver logger.Logger `json:"-"` LogCopier *logger.Copier `json:"-"` // contains filtered or unexported fields }
CommonContainer holds the fields for a container which are applicable across all platforms supported by the daemon.
type DetachError ¶
type DetachError struct{}
DetachError is special error which returned in case of container detach.
func (DetachError) Error ¶
func (DetachError) Error() string
type Health ¶
Health holds the current container health-check state
func (*Health) CloseMonitorChannel ¶
func (s *Health) CloseMonitorChannel()
CloseMonitorChannel closes any existing monitor channel.
func (*Health) OpenMonitorChannel ¶
func (s *Health) OpenMonitorChannel() chan struct{}
OpenMonitorChannel creates and returns a new monitor channel. If there already is one, it returns nil.
func (*Health) String ¶
String returns a human-readable description of the health-check state
type History ¶
type History []*Container
History is a convenience type for storing a list of containers, sorted by creation date in descendant order.
func (*History) Len ¶
Len returns the number of containers in the history.
func (*History) Less ¶
Less compares two containers and returns true if the second one was created before the first one.
func (*History) Swap ¶
Swap switches containers i and j positions in the history.
type Mount ¶
type Mount struct { Source string `json:"source"` Destination string `json:"destination"` Writable bool `json:"writable"` Data string `json:"data"` Propagation string `json:"mountpropagation"` }
Mount contains information for a mount operation.
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 RemovalInProgress bool // Not need for this to be persistent on disk. Dead bool Pid int StartedAt time.Time FinishedAt time.Time Health *Health // 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 ¶
func NewState() *State
NewState creates a default state object with a fresh channel for state changes.
func (*State) Error ¶
Error returns current error for the state.
func (*State) ExitCode ¶
ExitCode returns current exitcode for the state. Take lock before if state may be shared.
func (*State) GetPID ¶
GetPID holds the process id of a container.
func (*State) IsPaused ¶
IsPaused returns whether the container is paused or not.
func (*State) IsRestarting ¶
IsRestarting returns whether the container is restarting or not.
func (*State) IsRunning ¶
IsRunning returns whether the running flag is set. Used by Container to check whether a container is running.
func (*State) ResetRemovalInProgress ¶
func (s *State) ResetRemovalInProgress()
ResetRemovalInProgress make the RemovalInProgress state to false.
func (*State) SetDead ¶
func (s *State) SetDead()
SetDead sets the container state to "dead"
func (*State) SetError ¶
SetError sets the container's error state. This is useful when we want to know the error that occurred when container transits to another state when inspecting it
func (*State) SetExitCode ¶
SetExitCode set current exitcode for the state. Take lock before if state may be shared.
func (*State) SetRemovalInProgress ¶
SetRemovalInProgress sets the container state as being removed. It returns true if the container was already in that state.
func (*State) SetRestarting ¶
func (s *State) SetRestarting(exitStatus *ExitStatus)
SetRestarting sets the container state to "restarting". It also sets the container PID to 0.
func (*State) SetRestartingLocking ¶
func (s *State) SetRestartingLocking(exitStatus *ExitStatus)
SetRestartingLocking is when docker handles the auto restart of containers when they are in the middle of a stop and being restarted again
func (*State) SetRunning ¶
SetRunning sets the state of the container to "running".
func (*State) SetStopped ¶
func (s *State) SetStopped(exitStatus *ExitStatus)
SetStopped sets the container state to "stopped" without locking.
func (*State) SetStoppedLocking ¶
func (s *State) SetStoppedLocking(exitStatus *ExitStatus)
SetStoppedLocking locks the container state is sets it to "stopped".
func (*State) StateString ¶
StateString returns a single string to describe state
func (*State) String ¶
String returns a human-readable description of the state
func (*State) WaitStop ¶
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
func (*State) WaitWithContext ¶
WaitWithContext waits for the container to stop. Optional context can be passed for canceling the request.
type Store ¶
type Store interface { // Add appends a new container to the store. Add(string, *Container) // Get returns a container from the store by the identifier it was stored with. Get(string) *Container // Delete removes a container from the store by the identifier it was stored with. Delete(string) // List returns a list of containers from the store. List() []*Container // Size returns the number of containers in the store. Size() int // First returns the first container found in the store by a given filter. First(StoreFilter) *Container // ApplyAll calls the reducer function with every container in the store. ApplyAll(StoreReducer) }
Store defines an interface that any container store must implement.
func NewMemoryStore ¶
func NewMemoryStore() Store
NewMemoryStore initializes a new memory store.
type StoreFilter ¶
type StoreFilter func(*Container) bool
StoreFilter defines a function to filter container in the store.
type StoreReducer ¶
type StoreReducer func(*Container)
StoreReducer defines a function to manipulate containers in the store
Source Files ¶
archive.go container.go health.go history.go memory_store.go monitor.go mounts_unix.go state.go store.go
- Version
- v1.12.0-rc3
- Published
- Jul 1, 2016
- Platform
- js/wasm
- Imports
- 41 packages
- Last checked
- 1 minute ago –
Tools for package owners.