github.com/moby/docker@v26.1.3+incompatible/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, options container.ExecStartOptions) 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 ContainerExport(ctx context.Context, name string, out io.Writer) error 28 ContainerExtractToDir(name, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) error 29 ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) 30 } 31 32 // stateBackend includes functions to implement to provide container state lifecycle functionality. 33 type stateBackend interface { 34 ContainerCreate(ctx context.Context, config backend.ContainerCreateConfig) (container.CreateResponse, error) 35 ContainerKill(name string, signal string) error 36 ContainerPause(name string) error 37 ContainerRename(oldName, newName string) error 38 ContainerResize(name string, height, width int) error 39 ContainerRestart(ctx context.Context, name string, options container.StopOptions) error 40 ContainerRm(name string, config *backend.ContainerRmConfig) error 41 ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error 42 ContainerStop(ctx context.Context, name string, options container.StopOptions) error 43 ContainerUnpause(name string) error 44 ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error) 45 ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error) 46 } 47 48 // monitorBackend includes functions to implement to provide containers monitoring functionality. 49 type monitorBackend interface { 50 ContainerChanges(ctx context.Context, name string) ([]archive.Change, error) 51 ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error) 52 ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error) 53 ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error 54 ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) 55 Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error) 56 } 57 58 // attachBackend includes function to implement to provide container attaching functionality. 59 type attachBackend interface { 60 ContainerAttach(name string, c *backend.ContainerAttachConfig) error 61 } 62 63 // systemBackend includes functions to implement to provide system wide containers functionality 64 type systemBackend interface { 65 ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error) 66 } 67 68 type commitBackend interface { 69 CreateImageFromContainer(ctx context.Context, name string, config *backend.CreateImageConfig) (imageID string, err error) 70 } 71 72 // Backend is all the methods that need to be implemented to provide container specific functionality. 73 type Backend interface { 74 commitBackend 75 execBackend 76 copyBackend 77 stateBackend 78 monitorBackend 79 attachBackend 80 systemBackend 81 }