Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
c078768
containerd/pull: Use authorization
vvoland Jul 6, 2022
44891e8
add support for image inspect
ndeloof Jul 6, 2022
d33ed16
produce progress events polling ctrd's content.Store
ndeloof Jul 8, 2022
b5b5ae6
Implement ImageDelete for containerd
rumpl Jul 8, 2022
0fc8606
add support for image tag
ndeloof Jul 11, 2022
da50abf
add image load/save support
ndeloof Jul 11, 2022
af2911a
containerd: Unpack loaded images
vvoland Jul 7, 2022
dea9140
containerd: Implement push
vvoland Jul 8, 2022
8c90f88
compute image's shared size
ndeloof Jul 11, 2022
215028f
containerd: Push progress
vvoland Jul 6, 2022
7d8b3ff
daemon/containerd: Implement prune
vvoland Jul 19, 2022
d2ecfa6
containerd/auth: Check if registry hostname matches
vvoland Jul 21, 2022
dde365f
compute container's layer size
ndeloof Jul 12, 2022
df9e5a2
Implement run using the containerd snapshotter
rumpl Jul 25, 2022
c89f274
introduce GetImageOpts to manage image inspect data in backend
ndeloof Jul 25, 2022
b7fe4ea
implement docker system df
ndeloof Jul 28, 2022
4233177
introduce image.EventLogger to manage image lifecycle events
ndeloof Jul 28, 2022
368e268
Make build and buildx work
rumpl Jul 27, 2022
523bc1a
Don't look at graphdriver data if using containerd
rumpl Aug 1, 2022
e118033
Only use the image exporter in build if we don't use containerd
rumpl Aug 1, 2022
925f4f1
hack/emptyfs: Produce newer image layout
vvoland Jul 22, 2022
576c4d7
integration-cli: Correct emptyfs id under c8d
vvoland Jul 28, 2022
7b41cef
containerd/load: Load all platforms
vvoland Jul 25, 2022
53f123d
containerd/save: Export only present platform manifests
vvoland Jul 25, 2022
a03029b
Introduce support for docker commit
ndeloof Aug 4, 2022
3868cb5
run hack/vendor.sh
vvoland Aug 4, 2022
65b6bab
Merge pull request #31 from vvoland/containerd-emptyfs-modern
rumpl Aug 4, 2022
dab01b5
Merge pull request #37 from ndeloof/docker_commit
ndeloof Aug 4, 2022
8da3075
Fix linting issues
rumpl Aug 4, 2022
0c46327
Merge pull request #43 from rumpl/fix-linter
rumpl Aug 4, 2022
120c4ba
Merge pull request #33 from vvoland/containerd-export-convert
vvoland Aug 5, 2022
94929dd
Merge pull request #41 from vvoland/containerd-vendor-otel
vvoland Aug 8, 2022
8c57c43
Fix `docker system df`
rumpl Aug 8, 2022
e274a6e
Merge pull request #46 from rumpl/fix-system-df
rumpl Aug 8, 2022
99655cc
Make the snapshotter configurable
rumpl Aug 3, 2022
e645f73
c8d/daemon: Treat (storage/graph)Driver as snapshotter
vvoland Aug 5, 2022
4b035c9
Merge pull request #40 from rumpl/snapshotter-configuration
thaJeztah Aug 9, 2022
ca9d2bb
c8d/pull: Add options for stargz/nydus snapshotters
vvoland Aug 4, 2022
7d66397
let buildx know we support containerd snapshotter
ndeloof Aug 9, 2022
ed67239
Merge pull request #42 from vvoland/containerd-snapshotters-opts
rumpl Aug 9, 2022
a7499e6
Merge pull request #50 from ndeloof/buildx
rumpl Aug 10, 2022
d63a86b
Don't try to restore containers on restart with contaienrd
rumpl Aug 10, 2022
ccb236d
Pass the current snapshotter to the buildkit worker
rumpl Aug 10, 2022
7b5ae4c
Merge pull request #51 from rumpl/feat-no-restore
rumpl Aug 10, 2022
1f34a50
Merge pull request #52 from rumpl/fix-build-snapshotter
ndeloof Aug 10, 2022
e89f6e6
Don't remove containerd's container after exit
rumpl Aug 9, 2022
75ab036
ContainerChanges is not implemented by snapshotter-based ImageService
ndeloof Aug 10, 2022
4551c32
Merge pull request #47 from rumpl/feat-start
rumpl Aug 10, 2022
4b03892
daemon: Fix not initialized network controller
vvoland Aug 10, 2022
3793845
Merge pull request #54 from vvoland/containerd-no-restore-fix
rumpl Aug 10, 2022
c68a3c2
GetImage to return image tags with details
ndeloof Aug 11, 2022
da0ac40
list images matching digest to discover all tags
ndeloof Aug 11, 2022
c8a429d
prefer error over panic where possible
ndeloof Aug 12, 2022
f0464e4
Merge pull request #55 from ndeloof/image_inspect
ndeloof Aug 12, 2022
f11b75c
Merge pull request #53 from ndeloof/docker_diff
ndeloof Aug 12, 2022
300ddad
remove GetLayerByID from ImageService interface
ndeloof Aug 5, 2022
5df7465
Merge pull request #45 from ndeloof/GetLayerByID
ndeloof Aug 12, 2022
5f16ca5
builder-next: reenable runc executor
tonistiigi Aug 13, 2022
e54c52c
builder-next: enable more cache backends
tonistiigi Aug 13, 2022
f321200
Merge pull request #58 from tonistiigi/builder-cache-enable
rumpl Aug 16, 2022
11c4ee2
Merge pull request #57 from tonistiigi/builder-net-enable
rumpl Aug 17, 2022
e132b0d
c8d/prune: Handle filters, don't delete used
vvoland Aug 16, 2022
8523afd
Create a lease for the snapshots we prepare
rumpl Aug 17, 2022
eb228ea
Use getImage() to get the image when deleting
rumpl Aug 17, 2022
e3d77a1
c8d/exporter: Use configured snapshotter instead of default
vvoland Aug 17, 2022
4182674
Merge pull request #63 from vvoland/c8d-performmwithbasefs-fixsnapsho…
vvoland Aug 17, 2022
dacb507
c8d/pull: Don't unpack manually
vvoland Aug 17, 2022
6630bef
Merge pull request #62 from rumpl/fix-snapshot-gc
rumpl Aug 17, 2022
ffb9cae
Merge pull request #61 from rumpl/delete-get-image
rumpl Aug 17, 2022
42fea05
Merge pull request #64 from vvoland/c8d-pull-unpack
rumpl Aug 17, 2022
71c723b
daemon/config: remove unused DefaultContainerdSnapshotter
thaJeztah Aug 18, 2022
56df6be
Merge pull request #66 from thaJeztah/rumpl_remove_unused_const
thaJeztah Aug 18, 2022
471a671
Merge pull request #60 from vvoland/containerd-prune-filters
vvoland Aug 18, 2022
ac7ea9e
Add ExposedPorts and Volumes to the image returned
rumpl Aug 18, 2022
156ab63
c8d/daemon: Mount root and fill BaseFS
vvoland Aug 17, 2022
be299b0
Merge pull request #65 from vvoland/c8d-set-basefs-hack
rumpl Aug 19, 2022
c7a94e2
Merge pull request #68 from rumpl/fix-image-config
rumpl Aug 19, 2022
63aaf26
Implement image history
rumpl Aug 19, 2022
7a91b74
Pass the containerd client when Applying oci options
rumpl Aug 19, 2022
ca1b1f3
Merge pull request #70 from rumpl/fix-oci-spec
rumpl Aug 19, 2022
506199e
Merge pull request #69 from rumpl/image-history
rumpl Aug 19, 2022
6d660b1
ImageService: rename GraphDriverName to StorageDriver
thaJeztah Aug 9, 2022
e6d2633
daemon: info: fillDriverInfo() get driver-name from ImageService
thaJeztah Aug 9, 2022
b7994b5
daemon: containerStart(): get driver-name from ImageService
thaJeztah Aug 9, 2022
d3ecc3b
daemon: createSpec: get driver-name from ImageService
thaJeztah Aug 9, 2022
387662a
daemon: create(): get driver-name from ImageService
thaJeztah Aug 9, 2022
9abf944
daemon: remove daemon.graphdriver
thaJeztah Aug 9, 2022
3183019
Merge pull request #67 from thaJeztah/daemon_remove_graphdriver_field…
thaJeztah Aug 22, 2022
fd82202
daemon: containerStart() keep container's snapshotter
thaJeztah Aug 19, 2022
aa44c06
Merge pull request #71 from thaJeztah/rumpl_constainer_start_driver
thaJeztah Aug 22, 2022
ce5b73f
daemon: containerStart(): optimize logic
thaJeztah Aug 19, 2022
54ce8ed
info: add driver-type
thaJeztah Aug 22, 2022
65789b7
integration-cli: add utility to check if snapshotters are enabled
thaJeztah Aug 22, 2022
0a50868
c8d/progress: Fix progress not ending
vvoland Aug 23, 2022
c7f29d8
image commit: use configured snapshotter instead of default
thaJeztah Aug 24, 2022
c683230
daemon: remove SnapshotterFromGraphDriver mapping
thaJeztah Aug 24, 2022
78fc344
Merge pull request #72 from thaJeztah/rumpl_container_start_cleanup
thaJeztah Aug 24, 2022
23aff56
Merge pull request #75 from thaJeztah/rumpl_daemon_info_driver_type
thaJeztah Aug 24, 2022
6acac06
Merge pull request #73 from vvoland/c8d-push-error
thaJeztah Aug 24, 2022
602d43c
Merge pull request #77 from thaJeztah/rumpl_remove_graphdriver_mapping
thaJeztah Aug 24, 2022
390ff8e
Merge pull request #76 from thaJeztah/rumpl_commit_use_correct_snapsh…
rumpl Aug 25, 2022
d6d5644
registry: move v1 endpoint tests to endpoint_test.go
thaJeztah Aug 25, 2022
e666f99
registry: rename v1-endpoint tests to have a common prefix
thaJeztah Aug 25, 2022
5fa0225
registry: move search-related code to separate files
thaJeztah Aug 25, 2022
9bcec34
daemon: split image search to a separate service
thaJeztah Mar 11, 2022
a41d2a5
registry: remove Service interface
thaJeztah Aug 25, 2022
cf0b3d6
c8d/push: Push lazy blobs with distribution source labels
vvoland Aug 24, 2022
39c445a
Merge pull request #74 from vvoland/c8d-push-lazy-blobs
vvoland Aug 25, 2022
c9dccb9
Merge pull request #78 from thaJeztah/rumpl_search_split_search_service
thaJeztah Aug 25, 2022
ceb484d
daemon: set containerd default snapshotter if none is configured
thaJeztah Aug 25, 2022
e4cd5b9
Merge pull request #79 from thaJeztah/rumpl_default_snapshotter
thaJeztah Aug 26, 2022
180ed08
c8d/progress: Don't use cancelled context
vvoland Sep 1, 2022
cfaba5b
c8d/push: Fetch missing resources that can't be mounted
vvoland Sep 1, 2022
6c6f1af
Preserve Labels during docker tag
ndeloof Sep 7, 2022
692a4b0
Merge pull request #85 from ndeloof/tag_labels
rumpl Sep 8, 2022
c6836be
Set the user on exec
rumpl Sep 8, 2022
e13de6c
Merge pull request #80 from vvoland/c8d-push-lazy-fetch
rumpl Sep 12, 2022
861d0c3
Merge pull request #83 from vvoland/c8d-progress-cancelled-context
rumpl Sep 12, 2022
a8b5886
c8d/resolver: Use hosts from daemon configuration
ndeloof Sep 12, 2022
36dab47
c8d/resolver: Fallback to http for insecure registries
vvoland Sep 1, 2022
2dc8328
Refactor resolving/getting images
rumpl Sep 12, 2022
09e893a
Merge pull request #84 from ndeloof/c8d-resolver-hosts
rumpl Sep 12, 2022
e001249
Merge pull request #86 from rumpl/exec-user
rumpl Sep 12, 2022
3616b07
detect HTTP response to HTTPS request
ndeloof Sep 13, 2022
6b14e99
Merge pull request #89 from ndeloof/resolver_next
rumpl Sep 13, 2022
812646a
Merge pull request #88 from rumpl/refactor-images
ndeloof Sep 13, 2022
98e504a
Return the image ID on inspect
rumpl Sep 13, 2022
98e2bae
introduce Changes in image service API
ndeloof Sep 12, 2022
75d7cd1
Merge pull request #90 from rumpl/image-inspect-id
rumpl Sep 14, 2022
90f6cee
add support for docker diff
ndeloof Sep 15, 2022
1e04143
mount container's filesystem RO to avoid conflicts
ndeloof Sep 15, 2022
2419a81
Merge pull request #91 from ndeloof/containerd_diff
rumpl Sep 15, 2022
db1e32d
Make sure the mount is readonly when searching for a user/group
rumpl Sep 15, 2022
89078f3
Merge pull request #92 from rumpl/fix-run-user
rumpl Sep 16, 2022
9a93e97
contrib.mac: Resurrect install bundle script
chris-crone Sep 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/server/backend/build/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// ImageComponent provides an interface for working with images
type ImageComponent interface {
SquashImage(from string, to string) (string, error)
TagImageWithReference(image.ID, reference.Named) error
TagImageWithReference(context.Context, image.ID, reference.Named) error
}

// Builder defines interface for running a build
Expand Down Expand Up @@ -93,7 +93,7 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string
fmt.Fprintf(stdout, "Successfully built %s\n", stringid.TruncateID(imageID))
}
if imageID != "" {
err = tagger.TagImages(image.ID(imageID))
err = tagger.TagImages(ctx, image.ID(imageID))
}
return imageID, err
}
Expand Down
5 changes: 3 additions & 2 deletions api/server/backend/build/tag.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package build // import "github.com/docker/docker/api/server/backend/build"

import (
"context"
"fmt"
"io"

Expand Down Expand Up @@ -31,9 +32,9 @@ func NewTagger(backend ImageComponent, stdout io.Writer, names []string) (*Tagge
}

// TagImages creates image tags for the imageID
func (bt *Tagger) TagImages(imageID image.ID) error {
func (bt *Tagger) TagImages(ctx context.Context, imageID image.ID) error {
for _, rt := range bt.repoAndTags {
if err := bt.imageComponent.TagImageWithReference(imageID, rt); err != nil {
if err := bt.imageComponent.TagImageWithReference(ctx, imageID, rt); err != nil {
return err
}
fmt.Fprintf(bt.stdout, "Successfully tagged %s\n", reference.FamiliarString(rt))
Expand Down
14 changes: 7 additions & 7 deletions api/server/router/container/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ type execBackend interface {
type copyBackend interface {
ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)
ContainerCopy(name string, res string) (io.ReadCloser, error)
ContainerExport(name string, out io.Writer) error
ContainerExport(ctx context.Context, name string, out io.Writer) error
ContainerExtractToDir(name, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) error
ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)
}

// stateBackend includes functions to implement to provide container state lifecycle functionality.
type stateBackend interface {
ContainerCreate(config types.ContainerCreateConfig) (container.CreateResponse, error)
ContainerCreate(ctx context.Context, config types.ContainerCreateConfig) (container.CreateResponse, error)
ContainerKill(name string, signal string) error
ContainerPause(name string) error
ContainerRename(oldName, newName string) error
ContainerResize(name string, height, width int) error
ContainerRestart(ctx context.Context, name string, options container.StopOptions) error
ContainerRm(name string, config *types.ContainerRmConfig) error
ContainerStart(name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
ContainerStart(ctx context.Context, name string, hostConfig *container.HostConfig, checkpoint string, checkpointDir string) error
ContainerStop(ctx context.Context, name string, options container.StopOptions) error
ContainerUnpause(name string) error
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error)
Expand All @@ -48,13 +48,13 @@ type stateBackend interface {

// monitorBackend includes functions to implement to provide containers monitoring functionality.
type monitorBackend interface {
ContainerChanges(name string) ([]archive.Change, error)
ContainerInspect(name string, size bool, version string) (interface{}, error)
ContainerChanges(ctx context.Context, name string) ([]archive.Change, error)
ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error)
ContainerLogs(ctx context.Context, name string, config *types.ContainerLogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)

Containers(config *types.ContainerListOptions) ([]*types.Container, error)
Containers(ctx context.Context, config *types.ContainerListOptions) ([]*types.Container, error)
}

// attachBackend includes function to implement to provide container attaching functionality.
Expand All @@ -68,7 +68,7 @@ type systemBackend interface {
}

type commitBackend interface {
CreateImageFromContainer(name string, config *backend.CreateImageConfig) (imageID string, err error)
CreateImageFromContainer(ctx context.Context, name string, config *backend.CreateImageConfig) (imageID string, err error)
}

// Backend is all the methods that need to be implemented to provide container specific functionality.
Expand Down
12 changes: 6 additions & 6 deletions api/server/router/container/container_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter,
Changes: r.Form["changes"],
}

imgID, err := s.backend.CreateImageFromContainer(r.Form.Get("container"), commitCfg)
imgID, err := s.backend.CreateImageFromContainer(ctx, r.Form.Get("container"), commitCfg)
if err != nil {
return err
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response
config.Limit = limit
}

containers, err := s.backend.Containers(config)
containers, err := s.backend.Containers(ctx, config)
if err != nil {
return err
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response
}

func (s *containerRouter) getContainersExport(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return s.backend.ContainerExport(vars["name"], w)
return s.backend.ContainerExport(ctx, vars["name"], w)
}

type bodyOnStartError struct{}
Expand Down Expand Up @@ -214,7 +214,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon

checkpoint := r.Form.Get("checkpoint")
checkpointDir := r.Form.Get("checkpoint-dir")
if err := s.backend.ContainerStart(vars["name"], hostConfig, checkpoint, checkpointDir); err != nil {
if err := s.backend.ContainerStart(ctx, vars["name"], hostConfig, checkpoint, checkpointDir); err != nil {
return err
}

Expand Down Expand Up @@ -397,7 +397,7 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
}

func (s *containerRouter) getContainersChanges(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
changes, err := s.backend.ContainerChanges(vars["name"])
changes, err := s.backend.ContainerChanges(ctx, vars["name"])
if err != nil {
return err
}
Expand Down Expand Up @@ -578,7 +578,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
hostConfig.PidsLimit = nil
}

ccr, err := s.backend.ContainerCreate(types.ContainerCreateConfig{
ccr, err := s.backend.ContainerCreate(ctx, types.ContainerCreateConfig{
Name: name,
Config: config,
HostConfig: hostConfig,
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/container/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (s *containerRouter) getContainersByName(ctx context.Context, w http.Respon
displaySize := httputils.BoolValue(r, "size")

version := httputils.VersionFromContext(ctx)
json, err := s.backend.ContainerInspect(vars["name"], displaySize, version)
json, err := s.backend.ContainerInspect(ctx, vars["name"], displaySize, version)
if err != nil {
return err
}
Expand Down
20 changes: 13 additions & 7 deletions api/server/router/image/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ type Backend interface {

type imageBackend interface {
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error)
Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error)
GetImage(refOrID string, platform *specs.Platform) (retImg *dockerimage.Image, retErr error)
TagImage(imageName, repository, tag string) (string, error)
GetImage(ctx context.Context, refOrID string, options image.GetImageOpts) (*dockerimage.Image, error)
TagImage(ctx context.Context, imageName, repository, tag string) (string, error)
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
}

type importExportBackend interface {
LoadImage(inTar io.ReadCloser, outStream io.Writer, quiet bool) error
ImportImage(src string, repository string, platform *specs.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
ExportImage(names []string, outStream io.Writer) error
LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
ImportImage(ctx context.Context, src string, repository string, platform *specs.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
ExportImage(ctx context.Context, names []string, outStream io.Writer) error
}

type registryBackend interface {
PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, image, tag string, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
SearchRegistryForImages(ctx context.Context, searchFilters filters.Args, term string, limit int, authConfig *registry.AuthConfig, metaHeaders map[string][]string) (*registry.SearchResults, error)
}

// SearchBackend provides the backend to search registries for images.
type SearchBackend interface {
// SearchImages queries the registry for images matching the given term and
// options.
SearchImages(ctx context.Context, term string, opts registry.SearchOpts) (*registry.SearchResults, error)
}
4 changes: 3 additions & 1 deletion api/server/router/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import (
// imageRouter is a router to talk with the image controller
type imageRouter struct {
backend Backend
searchBackend SearchBackend
referenceBackend reference.Store
imageStore image.Store
layerStore layer.Store
routes []router.Route
}

// NewRouter initializes a new image router
func NewRouter(backend Backend, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
func NewRouter(backend Backend, searchBackend SearchBackend, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
r := &imageRouter{
backend: backend,
searchBackend: searchBackend,
referenceBackend: referenceBackend,
imageStore: imageStore,
layerStore: layerStore,
Expand Down
55 changes: 19 additions & 36 deletions api/server/router/image/image_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
opts "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/streamformatter"
specs "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -68,7 +68,7 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
progressErr = s.backend.PullImage(ctx, image, tag, platform, metaHeaders, authConfig, output)
} else { // import
src := r.Form.Get("fromSrc")
progressErr = s.backend.ImportImage(src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
progressErr = s.backend.ImportImage(ctx, src, repo, platform, tag, message, r.Body, output, r.Form["changes"])
}
if progressErr != nil {
if !output.Flushed() {
Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter, r
names = r.Form["names"]
}

if err := s.backend.ExportImage(names, output); err != nil {
if err := s.backend.ExportImage(ctx, names, output); err != nil {
if !output.Flushed() {
return err
}
Expand All @@ -156,7 +156,7 @@ func (s *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter,

output := ioutils.NewWriteFlusher(w)
defer output.Close()
if err := s.backend.LoadImage(r.Body, output, quiet); err != nil {
if err := s.backend.LoadImage(ctx, r.Body, output, quiet); err != nil {
_, _ = output.Write(streamformatter.FormatError(err))
}
return nil
Expand Down Expand Up @@ -193,7 +193,7 @@ func (s *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter, r
}

func (s *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
image, err := s.backend.GetImage(vars["name"], nil)
image, err := s.backend.GetImage(ctx, vars["name"], opts.GetImageOpts{Details: true})
if err != nil {
return err
}
Expand All @@ -207,10 +207,9 @@ func (s *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter
}

func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, error) {
refs := s.referenceBackend.References(img.ID().Digest())
repoTags := []string{}
repoDigests := []string{}
for _, ref := range refs {
for _, ref := range img.Details.References {
switch ref.(type) {
case reference.NamedTagged:
repoTags = append(repoTags, reference.FamiliarString(ref))
Expand All @@ -219,32 +218,11 @@ func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, err
}
}

var size int64
var layerMetadata map[string]string
layerID := img.RootFS.ChainID()
if layerID != "" {
l, err := s.layerStore.Get(layerID)
if err != nil {
return nil, err
}
defer layer.ReleaseAndLog(s.layerStore, l)
size = l.Size()
layerMetadata, err = l.Metadata()
if err != nil {
return nil, err
}
}

comment := img.Comment
if len(comment) == 0 && len(img.History) > 0 {
comment = img.History[len(img.History)-1].Comment
}

lastUpdated, err := s.imageStore.GetLastUpdated(img.ID())
if err != nil {
return nil, err
}

return &types.ImageInspect{
ID: img.ID().String(),
RepoTags: repoTags,
Expand All @@ -261,15 +239,15 @@ func (s *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, err
Variant: img.Variant,
Os: img.OperatingSystem(),
OsVersion: img.OSVersion,
Size: size,
VirtualSize: size, // TODO: field unused, deprecate
Size: img.Details.Size,
VirtualSize: img.Details.Size, // TODO: field unused, deprecate
GraphDriver: types.GraphDriverData{
Name: s.layerStore.DriverName(),
Data: layerMetadata,
Name: img.Details.Driver,
Data: img.Details.Metadata,
},
RootFS: rootFSToAPIType(img.RootFS),
Metadata: types.ImageMetadata{
LastTagTime: lastUpdated,
LastTagTime: img.Details.LastUpdated,
},
}, nil
}
Expand Down Expand Up @@ -324,7 +302,7 @@ func (s *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,

func (s *imageRouter) getImagesHistory(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
name := vars["name"]
history, err := s.backend.ImageHistory(name)
history, err := s.backend.ImageHistory(ctx, name)
if err != nil {
return err
}
Expand All @@ -336,7 +314,7 @@ func (s *imageRouter) postImagesTag(ctx context.Context, w http.ResponseWriter,
if err := httputils.ParseForm(r); err != nil {
return err
}
if _, err := s.backend.TagImage(vars["name"], r.Form.Get("repo"), r.Form.Get("tag")); err != nil {
if _, err := s.backend.TagImage(ctx, vars["name"], r.Form.Get("repo"), r.Form.Get("tag")); err != nil {
return err
}
w.WriteHeader(http.StatusCreated)
Expand Down Expand Up @@ -371,7 +349,12 @@ func (s *imageRouter) getImagesSearch(ctx context.Context, w http.ResponseWriter
// For a search it is not an error if no auth was given. Ignore invalid
// AuthConfig to increase compatibility with the existing API.
authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
query, err := s.backend.SearchRegistryForImages(ctx, searchFilters, r.Form.Get("term"), limit, authConfig, headers)
query, err := s.searchBackend.SearchImages(ctx, r.Form.Get("term"), registry.SearchOpts{
Filters: searchFilters,
Limit: limit,
AuthConfig: authConfig,
Headers: headers,
})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/swarm/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type Backend interface {
Init(req types.InitRequest) (string, error)
Join(req types.JoinRequest) error
Leave(force bool) error
Leave(ctx context.Context, force bool) error
Inspect() (types.Swarm, error)
Update(uint64, types.Spec, types.UpdateFlags) error
GetUnlockKey() (string, error)
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/swarm/cluster_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (sr *swarmRouter) leaveCluster(ctx context.Context, w http.ResponseWriter,
}

force := httputils.BoolValue(r, "force")
return sr.backend.Leave(force)
return sr.backend.Leave(ctx, force)
}

func (sr *swarmRouter) inspectCluster(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
Expand Down
2 changes: 1 addition & 1 deletion api/server/router/system/system_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
var getContainers, getImages, getVolumes, getBuildCache bool
typeStrs, ok := r.Form["type"]
if versions.LessThan(version, "1.42") || !ok {
getContainers, getImages, getVolumes, getBuildCache = true, true, true, true
getContainers, getImages, getVolumes, getBuildCache = true, true, true, s.builder != nil
} else {
for _, typ := range typeStrs {
switch types.DiskUsageObject(typ) {
Expand Down
9 changes: 9 additions & 0 deletions api/types/image/opts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package image

import specs "github.com/opencontainers/image-spec/specs-go/v1"

// GetImageOpts holds parameters to inspect an image.
type GetImageOpts struct {
Platform *specs.Platform
Details bool
}
Loading