Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 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
4f1a984
c8d/daemon: Add remote snapshotters to config
vvoland Aug 4, 2022
d930a4a
dockerd/config: Configurable snapshotter sock address
vvoland Aug 4, 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
10 changes: 5 additions & 5 deletions api/server/router/container/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ type copyBackend interface {

// 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 @@ -49,12 +49,12 @@ 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)
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
8 changes: 4 additions & 4 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 @@ -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 @@ -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
12 changes: 6 additions & 6 deletions api/server/router/image/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ 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 {
Expand Down
45 changes: 12 additions & 33 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 @@ -219,32 +219,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 +240,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 +303,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 +315,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
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