{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package container\n\n## Constants\n\n```go\nconst DefaultSHMSize int64 = 67108864\n```\nDefaultSHMSize is the default size (64MB) of the SHM which will be mounted in the container\n\n## Functions\n\n```go\nfunc AttachStreams(streamConfig *runconfig.StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer, keys []byte) chan error\n```\nAttachStreams connects streams to a TTY. Used by exec too. Should this move somewhere else?\n\n```go\nfunc IsValidStateString(s string) bool\n```\nIsValidStateString checks if the provided string is a valid container state or not.\n\n## Types\n\n```go\ntype CommonContainer struct {\n\t*runconfig.StreamConfig\n\t// embed for Container to support states directly.\n\t*State          `json:\"State\"` // Needed for remote api version \u003c= 1.11\n\tRoot            string         `json:\"-\"` // Path to the \"home\" of the container, including metadata.\n\tBaseFS          string         `json:\"-\"` // Path to the graphdriver mountpoint\n\tRWLayer         layer.RWLayer  `json:\"-\"`\n\tID              string\n\tCreated         time.Time\n\tPath            string\n\tArgs            []string\n\tConfig          *containertypes.Config\n\tImageID         image.ID `json:\"Image\"`\n\tNetworkSettings *network.Settings\n\tLogPath         string\n\tName            string\n\tDriver          string\n\t// MountLabel contains the options for the 'mount' command\n\tMountLabel             string\n\tProcessLabel           string\n\tRestartCount           int\n\tHasBeenStartedBefore   bool\n\tHasBeenManuallyStopped bool // used for unless-stopped restart policy\n\tMountPoints            map[string]*volume.MountPoint\n\tHostConfig             *containertypes.HostConfig `json:\"-\"` // do not serialize the host config in the json, otherwise we'll make the container unportable\n\tCommand                *execdriver.Command        `json:\"-\"`\n\n\tExecCommands *exec.Store `json:\"-\"`\n\t// logDriver for closing\n\tLogDriver logger.Logger  `json:\"-\"`\n\tLogCopier *logger.Copier `json:\"-\"`\n\t// contains filtered or unexported fields\n}\n```\nCommonContainer holds the fields for a container which are applicable across all platforms supported by the daemon.\n\n```go\ntype Container struct {\n\tCommonContainer\n\n\t// Fields below here are platform specific.\n\tAppArmorProfile string\n\tHostnamePath    string\n\tHostsPath       string\n\tShmPath         string\n\tMqueuePath      string\n\tResolvConfPath  string\n\tSeccompProfile  string\n}\n```\nContainer holds the fields specific to unixen implementations. See CommonContainer for standard fields common to all containers.\n\n```go\nfunc NewBaseContainer(id, root string) *Container\n```\nNewBaseContainer creates a new container with its basic configuration.\n\n```go\nfunc (container *Container) AddBindMountPoint(name, source, destination string, rw bool)\n```\nAddBindMountPoint adds a new bind mount point configuration to the container.\n\n```go\nfunc (container *Container) AddLocalMountPoint(name, destination string, rw bool)\n```\nAddLocalMountPoint adds a new local mount point configuration to the container.\n\n```go\nfunc (container *Container) AddMountPointWithVolume(destination string, vol volume.Volume, rw bool)\n```\nAddMountPointWithVolume adds a new mount point configured with a volume to the container.\n\n```go\nfunc (container *Container) Attach(stdin io.ReadCloser, stdout io.Writer, stderr io.Writer, keys []byte) chan error\n```\nAttach connects to the container's TTY, delegating to standard streams or websockets depending on the configuration.\n\n```go\nfunc (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epConfig *network.EndpointSettings, sb libnetwork.Sandbox) ([]libnetwork.EndpointOption, error)\n```\nBuildCreateEndpointOptions builds endpoint options from a given network.\n\n```go\nfunc (container *Container) BuildEndpointInfo(n libnetwork.Network, ep libnetwork.Endpoint) error\n```\nBuildEndpointInfo sets endpoint-related fields on container.NetworkSettings based on the provided network and endpoint.\n\n```go\nfunc (container *Container) BuildHostnameFile() error\n```\nBuildHostnameFile writes the container's hostname file.\n\n```go\nfunc (container *Container) BuildJoinOptions(n libnetwork.Network) ([]libnetwork.EndpointOption, error)\n```\nBuildJoinOptions builds endpoint Join options from a given network.\n\n```go\nfunc (container *Container) ConfigPath() (string, error)\n```\nConfigPath returns the path to the container's JSON config\n\n```go\nfunc (container *Container) CopyImagePathContent(v volume.Volume, destination string) error\n```\nCopyImagePathContent copies files in destination to the volume.\n\n```go\nfunc (container *Container) CreateDaemonEnvironment(linkedEnv []string) []string\n```\nCreateDaemonEnvironment returns the list of all environment variables given the list of environment variables related to links. Sets PATH, HOSTNAME and if container.Config.Tty is set: TERM. The defaults set here do not override the values in container.Config.Env\n\n```go\nfunc (container *Container) ExitOnNext()\n```\nExitOnNext signals to the monitor that it should not restart the container after we send the kill signal.\n\n```go\nfunc (container *Container) FromDisk() error\n```\nFromDisk loads the container configuration stored in the host.\n\n```go\nfunc (container *Container) GetEndpointInNetwork(n libnetwork.Network) (libnetwork.Endpoint, error)\n```\nGetEndpointInNetwork returns the container's endpoint to the provided network.\n\n```go\nfunc (container *Container) GetExecIDs() []string\n```\nGetExecIDs returns the list of exec commands running on the container.\n\n```go\nfunc (container *Container) GetLogConfig(defaultConfig containertypes.LogConfig) containertypes.LogConfig\n```\nGetLogConfig returns the log configuration for the container.\n\n```go\nfunc (container *Container) GetMountLabel() string\n```\nGetMountLabel returns the mounting label for the container. This label is empty if the container is privileged.\n\n```go\nfunc (container *Container) GetProcessLabel() string\n```\nGetProcessLabel returns the process label for the container.\n\n```go\nfunc (container *Container) GetResourcePath(path string) (string, error)\n```\nGetResourcePath 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 \\`/\\`.\n\nThe 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.\n\nNOTE: The returned path is \\*only\\* safely scoped inside the container's BaseFS\n\n\tif no component of the returned path changes (such as a component\n\tsymlinking to a different path) between using this method and using the\n\tpath. See symlink.FollowSymlinkInScope for more details.\n\n```go\nfunc (container *Container) GetRootResourcePath(path string) (string, error)\n```\nGetRootResourcePath evaluates \\`path\\` in the scope of the container's root, with proper path sanitisation. Symlinks are all scoped to the root of the container, as though the container's root was \\`/\\`.\n\nThe root of a container is the host-facing configuration metadata directory. Only use this method to safely access the container's \\`container.json\\` or other metadata files. If in doubt, use container.GetResourcePath.\n\nNOTE: The returned path is \\*only\\* safely scoped inside the container's root\n\n\tif no component of the returned path changes (such as a component\n\tsymlinking to a different path) between using this method and using the\n\tpath. See symlink.FollowSymlinkInScope for more details.\n\n```go\nfunc (container *Container) HasMountFor(path string) bool\n```\nHasMountFor checks if path is a mountpoint\n\n```go\nfunc (container *Container) HostConfigPath() (string, error)\n```\nHostConfigPath returns the path to the container's JSON hostconfig\n\n```go\nfunc (container *Container) InitDNSHostConfig()\n```\nInitDNSHostConfig ensures that the dns fields are never nil. New containers don't ever have those fields nil, but pre created containers can still have those nil values. The non-recommended host configuration in the start api can make these fields nil again, this corrects that issue until we remove that behavior for good. See [https://github.com/docker/docker/pull/17779](https://github.com/docker/docker/pull/17779) for a more detailed explanation on why we don't want that.\n\n```go\nfunc (container *Container) IpcMounts() []execdriver.Mount\n```\nIpcMounts returns the list of IPC mounts\n\n```go\nfunc (container *Container) IsDestinationMounted(destination string) bool\n```\nIsDestinationMounted checks whether a path is mounted on the container or not.\n\n```go\nfunc (container *Container) MqueueResourcePath() (string, error)\n```\nMqueueResourcePath returns path to mqueue\n\n```go\nfunc (container *Container) NetworkMounts() []execdriver.Mount\n```\nNetworkMounts returns the list of network mounts.\n\n```go\nfunc (container *Container) Resize(h, w int) error\n```\nResize changes the TTY of the process running inside the container to the given height and width. The container must be running.\n\n```go\nfunc (container *Container) ResolvePath(path string) (resolvedPath, absPath string, err error)\n```\nResolvePath resolves the given path in the container to a resource on the host. Returns a resolved path (absolute path to the resource on the host), the absolute path to the resource relative to the container's rootfs, and a error if the path points to outside the container's rootfs.\n\n```go\nfunc (container *Container) SetupWorkingDirectory() error\n```\nSetupWorkingDirectory sets up the container's working directory as set in container.Config.WorkingDir\n\n```go\nfunc (container *Container) ShmResourcePath() (string, error)\n```\nShmResourcePath returns path to shm\n\n```go\nfunc (container *Container) ShouldRestart() bool\n```\nShouldRestart decides whether the daemon should restart the container or not. This is based on the container's restart policy.\n\n```go\nfunc (container *Container) StartLogger(cfg containertypes.LogConfig) (logger.Logger, error)\n```\nStartLogger starts a new logger driver for the container.\n\n```go\nfunc (container *Container) StartMonitor(s supervisor, policy container.RestartPolicy) error\n```\nStartMonitor initializes a containerMonitor for this container with the provided supervisor and restart policy and starts the container's process.\n\n```go\nfunc (container *Container) StatPath(resolvedPath, absPath string) (stat *types.ContainerPathStat, err error)\n```\nStatPath is the unexported version of StatPath. Locks and mounts should be acquired before calling this method and the given path should be fully resolved to a path on the host corresponding to the given absolute path inside the container.\n\n```go\nfunc (container *Container) StopSignal() int\n```\nStopSignal returns the signal used to stop the container.\n\n```go\nfunc (container *Container) TmpfsMounts() []execdriver.Mount\n```\nTmpfsMounts returns the list of tmpfs mounts\n\n```go\nfunc (container *Container) ToDisk() error\n```\nToDisk saves the container configuration on disk.\n\n```go\nfunc (container *Container) ToDiskLocking() error\n```\nToDiskLocking saves the container configuration on disk in a thread safe way.\n\n```go\nfunc (container *Container) TrySetNetworkMount(destination string, path string) bool\n```\nTrySetNetworkMount attempts to set the network mounts given a provided destination and the path to use for it; return true if the given destination was a network mount file\n\n```go\nfunc (container *Container) UnmountIpcMounts(unmount func(pth string) error)\n```\nUnmountIpcMounts uses the provided unmount function to unmount shm and mqueue if they were mounted\n\n```go\nfunc (container *Container) UnmountVolumes(forceSyscall bool, volumeEventLog func(name, action string, attributes map[string]string)) error\n```\nUnmountVolumes unmounts all volumes\n\n```go\nfunc (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error\n```\nUpdateContainer updates resources of a container.\n\n```go\nfunc (container *Container) UpdateJoinInfo(n libnetwork.Network, ep libnetwork.Endpoint) error\n```\nUpdateJoinInfo updates network settings when container joins network n with endpoint ep.\n\n```go\nfunc (container *Container) UpdateSandboxNetworkSettings(sb libnetwork.Sandbox) error\n```\nUpdateSandboxNetworkSettings updates the sandbox ID and Key.\n\n```go\nfunc (container *Container) WriteHostConfig() error\n```\nWriteHostConfig saves the host configuration on disk for the container.\n\n```go\ntype History []*Container\n```\nHistory is a convenience type for storing a list of containers, sorted by creation date in descendant order.\n\n```go\nfunc (history *History) Add(container *Container)\n```\nAdd the given container to history.\n\n```go\nfunc (history *History) Len() int\n```\nLen returns the number of containers in the history.\n\n```go\nfunc (history *History) Less(i, j int) bool\n```\nLess compares two containers and returns true if the second one was created before the first one.\n\n```go\nfunc (history *History) Swap(i, j int)\n```\nSwap switches containers i and j positions in the history.\n\n```go\ntype State struct {\n\tsync.Mutex\n\t// FIXME: Why do we have both paused and running if a\n\t// container cannot be paused and running at the same time?\n\tRunning           bool\n\tPaused            bool\n\tRestarting        bool\n\tOOMKilled         bool\n\tRemovalInProgress bool // Not need for this to be persistent on disk.\n\tDead              bool\n\tPid               int\n\tExitCode          int\n\tError             string // contains last known error when starting the container\n\tStartedAt         time.Time\n\tFinishedAt        time.Time\n\t// contains filtered or unexported fields\n}\n```\nState 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.\n\n```go\nfunc NewState() *State\n```\nNewState creates a default state object with a fresh channel for state changes.\n\n```go\nfunc (s *State) GetPID() int\n```\nGetPID holds the process id of a container.\n\n```go\nfunc (s *State) IsPaused() bool\n```\nIsPaused returns whether the container is paused or not.\n\n```go\nfunc (s *State) IsRestarting() bool\n```\nIsRestarting returns whether the container is restarting or not.\n\n```go\nfunc (s *State) IsRunning() bool\n```\nIsRunning returns whether the running flag is set. Used by Container to check whether a container is running.\n\n```go\nfunc (s *State) ResetRemovalInProgress()\n```\nResetRemovalInProgress make the RemovalInProgress state to false.\n\n```go\nfunc (s *State) SetDead()\n```\nSetDead sets the container state to \"dead\"\n\n```go\nfunc (s *State) SetError(err error)\n```\nSetError 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\n\n```go\nfunc (s *State) SetRemovalInProgress() error\n```\nSetRemovalInProgress sets the container state as being removed.\n\n```go\nfunc (s *State) SetRestarting(exitStatus *execdriver.ExitStatus)\n```\nSetRestarting sets the container state to \"restarting\". It also sets the container PID to 0.\n\n```go\nfunc (s *State) SetRestartingLocking(exitStatus *execdriver.ExitStatus)\n```\nSetRestartingLocking is when docker handles the auto restart of containers when they are in the middle of a stop and being restarted again\n\n```go\nfunc (s *State) SetRunning(pid int)\n```\nSetRunning sets the state of the container to \"running\".\n\n```go\nfunc (s *State) SetStopped(exitStatus *execdriver.ExitStatus)\n```\nSetStopped sets the container state to \"stopped\" without locking.\n\n```go\nfunc (s *State) SetStoppedLocking(exitStatus *execdriver.ExitStatus)\n```\nSetStoppedLocking locks the container state is sets it to \"stopped\".\n\n```go\nfunc (s *State) StateString() string\n```\nStateString returns a single string to describe state\n\n```go\nfunc (s *State) String() string\n```\nString returns a human-readable description of the state\n\n```go\nfunc (s *State) WaitStop(timeout time.Duration) (int, error)\n```\nWaitStop 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\n\n```go\ntype Store interface {\n\t// Add appends a new container to the store.\n\tAdd(string, *Container)\n\t// Get returns a container from the store by the identifier it was stored with.\n\tGet(string) *Container\n\t// Delete removes a container from the store by the identifier it was stored with.\n\tDelete(string)\n\t// List returns a list of containers from the store.\n\tList() []*Container\n\t// Size returns the number of containers in the store.\n\tSize() int\n\t// First returns the first container found in the store by a given filter.\n\tFirst(StoreFilter) *Container\n\t// ApplyAll calls the reducer function with every container in the store.\n\tApplyAll(StoreReducer)\n}\n```\nStore defines an interface that any container store must implement.\n\n```go\nfunc NewMemoryStore() Store\n```\nNewMemoryStore initializes a new memory store.\n\n```go\ntype StoreFilter func(*Container) bool\n```\nStoreFilter defines a function to filter container in the store.\n\n```go\ntype StoreReducer func(*Container)\n```\nStoreReducer defines a function to manipulate containers in the store\n\n","path":"github.com/hyperhq/hypercli/container","name":"container","synopsis":"","isRedistributable":true}
