github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/api/server/router/container/backend.go (about) 1 package container 2 3 import ( 4 "io" 5 "time" 6 7 "golang.org/x/net/context" 8 9 "github.com/docker/docker/api/types/backend" 10 "github.com/docker/docker/pkg/archive" 11 "github.com/docker/docker/pkg/version" 12 "github.com/docker/engine-api/types" 13 "github.com/docker/engine-api/types/container" 14 ) 15 16 // execBackend includes functions to implement to provide exec functionality. 17 type execBackend interface { 18 ContainerExecCreate(config *types.ExecConfig) (string, error) 19 ContainerExecInspect(id string) (*backend.ExecInspect, error) 20 ContainerExecResize(name string, height, width int) error 21 ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error 22 ExecExists(name string) (bool, error) 23 } 24 25 // copyBackend includes functions to implement to provide container copy functionality. 26 type copyBackend interface { 27 ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) 28 ContainerCopy(name string, res string) (io.ReadCloser, error) 29 ContainerExport(name string, out io.Writer) error 30 ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error 31 ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) 32 } 33 34 // stateBackend includes functions to implement to provide container state lifecycle functionality. 35 type stateBackend interface { 36 ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error) 37 ContainerKill(name string, sig uint64) error 38 ContainerPause(name string) error 39 ContainerRename(oldName, newName string) error 40 ContainerResize(name string, height, width int) error 41 ContainerRestart(name string, seconds int) error 42 ContainerRm(name string, config *types.ContainerRmConfig) error 43 ContainerStart(name string, hostConfig *container.HostConfig) error 44 ContainerStop(name string, seconds int) error 45 ContainerUnpause(name string) error 46 ContainerUpdate(name string, hostConfig *container.HostConfig) ([]string, error) 47 ContainerWait(name string, timeout time.Duration) (int, error) 48 } 49 50 // monitorBackend includes functions to implement to provide containers monitoring functionality. 51 type monitorBackend interface { 52 ContainerChanges(name string) ([]archive.Change, error) 53 ContainerInspect(name string, size bool, version version.Version) (interface{}, error) 54 ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error 55 ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error 56 ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) 57 58 Containers(config *types.ContainerListOptions) ([]*types.Container, error) 59 } 60 61 // attachBackend includes function to implement to provide container attaching functionality. 62 type attachBackend interface { 63 ContainerAttach(name string, c *backend.ContainerAttachConfig) error 64 } 65 66 // Backend is all the methods that need to be implemented to provide container specific functionality. 67 type Backend interface { 68 execBackend 69 copyBackend 70 stateBackend 71 monitorBackend 72 attachBackend 73 }