2018-02-05 21:05:59 +00:00
|
|
|
package container // import "github.com/docker/docker/api/server/router/container"
|
2015-11-05 01:38:05 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2016-03-25 18:33:54 +00:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
2016-09-06 18:46:37 +00:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-01-27 22:09:42 +00:00
|
|
|
"github.com/docker/docker/api/types/backend"
|
2016-09-06 18:46:37 +00:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2016-11-17 05:46:37 +00:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
2017-03-30 20:52:40 +00:00
|
|
|
containerpkg "github.com/docker/docker/container"
|
2015-11-05 01:38:05 +00:00
|
|
|
"github.com/docker/docker/pkg/archive"
|
|
|
|
)
|
|
|
|
|
2015-11-24 18:35:02 +00:00
|
|
|
// execBackend includes functions to implement to provide exec functionality.
|
|
|
|
type execBackend interface {
|
2016-04-13 08:33:46 +00:00
|
|
|
ContainerExecCreate(name string, config *types.ExecConfig) (string, error)
|
2016-02-10 20:16:59 +00:00
|
|
|
ContainerExecInspect(id string) (*backend.ExecInspect, error)
|
2015-11-05 01:38:05 +00:00
|
|
|
ContainerExecResize(name string, height, width int) error
|
2017-08-23 22:21:41 +00:00
|
|
|
ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
|
2015-11-24 18:35:02 +00:00
|
|
|
ExecExists(name string) (bool, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// copyBackend includes functions to implement to provide container copy functionality.
|
|
|
|
type copyBackend interface {
|
|
|
|
ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)
|
|
|
|
ContainerCopy(name string, res string) (io.ReadCloser, error)
|
2015-11-05 01:38:05 +00:00
|
|
|
ContainerExport(name string, out io.Writer) error
|
2016-11-14 13:37:08 +00:00
|
|
|
ContainerExtractToDir(name, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) error
|
2015-11-24 18:35:02 +00:00
|
|
|
ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// stateBackend includes functions to implement to provide container state lifecycle functionality.
|
|
|
|
type stateBackend interface {
|
2016-11-30 18:22:07 +00:00
|
|
|
ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
|
2015-11-05 01:38:05 +00:00
|
|
|
ContainerKill(name string, sig uint64) error
|
|
|
|
ContainerPause(name string) error
|
|
|
|
ContainerRename(oldName, newName string) error
|
|
|
|
ContainerResize(name string, height, width int) error
|
2016-06-07 03:29:05 +00:00
|
|
|
ContainerRestart(name string, seconds *int) error
|
2015-12-04 20:34:43 +00:00
|
|
|
ContainerRm(name string, config *types.ContainerRmConfig) error
|
2016-11-30 18:22:07 +00:00
|
|
|
ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
|
2016-06-07 03:29:05 +00:00
|
|
|
ContainerStop(name string, seconds *int) error
|
2015-11-05 01:38:05 +00:00
|
|
|
ContainerUnpause(name string) error
|
2016-11-30 18:22:07 +00:00
|
|
|
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error)
|
2017-03-31 03:01:41 +00:00
|
|
|
ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error)
|
2015-11-05 01:38:05 +00:00
|
|
|
}
|
2015-11-24 18:35:02 +00:00
|
|
|
|
|
|
|
// monitorBackend includes functions to implement to provide containers monitoring functionality.
|
|
|
|
type monitorBackend interface {
|
|
|
|
ContainerChanges(name string) ([]archive.Change, error)
|
2016-04-19 14:56:54 +00:00
|
|
|
ContainerInspect(name string, size bool, version string) (interface{}, error)
|
2017-07-19 14:20:13 +00:00
|
|
|
ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
|
2016-03-25 18:33:54 +00:00
|
|
|
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
|
2016-11-14 19:50:16 +00:00
|
|
|
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
|
2015-11-24 18:35:02 +00:00
|
|
|
|
2016-01-27 22:09:42 +00:00
|
|
|
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
|
2015-11-24 18:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// attachBackend includes function to implement to provide container attaching functionality.
|
|
|
|
type attachBackend interface {
|
2016-01-05 21:23:24 +00:00
|
|
|
ContainerAttach(name string, c *backend.ContainerAttachConfig) error
|
2015-11-24 18:35:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-23 23:25:43 +00:00
|
|
|
// systemBackend includes functions to implement to provide system wide containers functionality
|
|
|
|
type systemBackend interface {
|
2017-04-11 19:52:33 +00:00
|
|
|
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error)
|
2016-08-23 23:25:43 +00:00
|
|
|
}
|
|
|
|
|
2015-11-24 18:35:02 +00:00
|
|
|
// Backend is all the methods that need to be implemented to provide container specific functionality.
|
|
|
|
type Backend interface {
|
|
|
|
execBackend
|
|
|
|
copyBackend
|
|
|
|
stateBackend
|
|
|
|
monitorBackend
|
|
|
|
attachBackend
|
2016-08-23 23:25:43 +00:00
|
|
|
systemBackend
|
2015-11-24 18:35:02 +00:00
|
|
|
}
|