github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/moby/api/server/router/container/backend.go (about) 1 package container // import "github.com/docker/docker/api/server/router/container" 2 3 import ( 4 "context" 5 "io" 6 7 "github.com/docker/docker/api/types" 8 "github.com/docker/docker/api/types/backend" 9 "github.com/docker/docker/api/types/container" 10 "github.com/docker/docker/api/types/filters" 11 containerpkg "github.com/docker/docker/container" 12 "github.com/docker/docker/pkg/archive" 13 ) 14 15 // execBackend includes functions to implement to provide exec functionality. 16 type execBackend interface { 17 ContainerExecCreate(name string, config *types.ExecConfig) (string, error) 18 ContainerExecInspect(id string) (*backend.ExecInspect, error) 19 ContainerExecResize(name string, height, width int) error 20 ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error 21 ExecExists(name string) (bool, error) 22 } 23 24 // copyBackend includes functions to implement to provide container copy functionality. 25 type copyBackend interface { 26 ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) 27 ContainerCopy(name string, res string) (io.ReadCloser, error) 28 ContainerExport(name string, out io.Writer) error 29 ContainerExtractToDir(name, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) error 30 ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) 31 } 32 33 // stateBackend includes functions to implement to provide container state lifecycle functionality. 34 type stateBackend interface { 35 ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error) 36 ContainerKill(name string, sig uint64) error 37 ContainerPause(name string) error 38 ContainerRename(oldName, newName string) error 39 ContainerResize(name string, height, width int) error 40 ContainerRestart(name string, seconds *int) error 41 ContainerRm(name string, config *types.ContainerRmConfig) error 42 ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error 43 ContainerStop(name string, seconds *int) error 44 ContainerUnpause(name string) error 45 ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error) 46 ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error) 47 } 48 49 // monitorBackend includes functions to implement to provide containers monitoring functionality. 50 type monitorBackend interface { 51 ContainerChanges(name string) ([]archive.Change, error) 52 ContainerInspect(name string, size bool, version string) (interface{}, error) 53 ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) 54 ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error 55 ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) 56 57 Containers(config *types.ContainerListOptions) ([]*types.Container, error) 58 } 59 60 // attachBackend includes function to implement to provide container attaching functionality. 61 type attachBackend interface { 62 ContainerAttach(name string, c *backend.ContainerAttachConfig) error 63 } 64 65 // systemBackend includes functions to implement to provide system wide containers functionality 66 type systemBackend interface { 67 ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error) 68 } 69 70 type commitBackend interface { 71 CreateImageFromContainer(name string, config *backend.CreateImageConfig) (imageID string, err error) 72 } 73 74 // Backend is all the methods that need to be implemented to provide container specific functionality. 75 type Backend interface { 76 commitBackend 77 execBackend 78 copyBackend 79 stateBackend 80 monitorBackend 81 attachBackend 82 systemBackend 83 }