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