Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
131da7b
Revert "Revert "Remove the rest of v1 manifest support""
Jun 19, 2019
4a7720d
Revert "use gotest.tools assertions in docker_cli_push_test.go"
Jun 19, 2019
79115e6
Revert "Revert "Remove Schema1 integration test suite""
Jun 19, 2019
aa439df
distribution: remove v2 schema1 push
Jun 20, 2019
19b3220
daemon: do not mkdir trust directory
Jun 20, 2019
d1c3fe1
Use containerd client to pull images
dmcgowan Oct 16, 2018
f1d6d38
Use containerd to list images
dmcgowan Oct 17, 2018
0fd1042
Use containerd to create tags
dmcgowan Oct 27, 2018
dc92057
Add image cache
dmcgowan Oct 31, 2018
fd0f8fb
Add image tagging by id and reference
dmcgowan Dec 6, 2018
9c9d9c7
Add image deletion
dmcgowan Dec 11, 2018
caad972
Add support for layers
dmcgowan Dec 18, 2018
7ef9ca3
Add support for inspect
dmcgowan Jan 18, 2019
2b93cc8
Update image history to use containerd
dmcgowan Jan 23, 2019
7a06378
Add support for docker run
dmcgowan Jan 29, 2019
93e4ff8
Update image service functions to use containerd
dmcgowan Jan 30, 2019
a48af86
display docker pull progress for containerd integration
AntaresS Jan 31, 2019
e4de561
Add support for commit
dmcgowan Feb 6, 2019
85f2662
Add parent label to committed images
dmcgowan Feb 6, 2019
8435405
Update events handler to use containerd
dmcgowan Feb 8, 2019
177c889
Add push support through containerd
dmcgowan Feb 11, 2019
77e85ab
Update images to use manifest as image ID
dmcgowan Feb 12, 2019
bbe1d77
Add layer label to content
dmcgowan Feb 16, 2019
f5282b9
unpack layers simultaneously
AntaresS Feb 15, 2019
1091b0a
Resolve runtime image
dmcgowan Feb 25, 2019
9b2eb7a
unblock layer extracting to a separate thread
AntaresS Feb 25, 2019
b986874
Move layer creation to daemon package
dmcgowan Feb 26, 2019
fdc8926
Support for multiple layer stores
dmcgowan Mar 1, 2019
1b9f561
Update pull to use error groups
dmcgowan Mar 4, 2019
ba80e45
Lookup images by digest regexp
dmcgowan Mar 5, 2019
705fc4f
Use content label for inspecting layer store
dmcgowan Mar 5, 2019
84dfd57
Update pull to add canonical tag
dmcgowan Mar 5, 2019
501622f
Add test framework which sets up containerd
dmcgowan Mar 11, 2019
07decdb
Add delete image unit tests
dmcgowan Mar 13, 2019
e435ef2
Update rmi to use containerd gc
dmcgowan Mar 4, 2019
409437d
Fix pull lease cleanup to use new context
dmcgowan Mar 19, 2019
9f5379d
Add more rmi tests
dmcgowan Mar 19, 2019
2e4b735
Add os platform matcher
dmcgowan Mar 19, 2019
e57fc9c
Update commit to migrate layers
dmcgowan Mar 20, 2019
189f0cb
Update history to not rely on deprecated cache
dmcgowan Mar 20, 2019
ac32eda
Show digest tags from dangling images
dmcgowan Mar 20, 2019
d4036ec
Add size to docker images
dmcgowan Mar 20, 2019
479c9a3
Improve platform matching for containers and pull
dmcgowan Mar 20, 2019
f81d226
Remove deprecated cache
dmcgowan Mar 20, 2019
d02df56
Fix docker images filters
dmcgowan Mar 21, 2019
c9d7369
Optimize image list to skip size on skipped images
dmcgowan Mar 21, 2019
a354819
Fix image lookup and listing
dmcgowan Mar 21, 2019
3778719
Fix unit tests and lint
dmcgowan Mar 21, 2019
2fc1906
use containerd client to create image during build
AntaresS Mar 8, 2019
28decab
Fix CI linting
dmcgowan Mar 22, 2019
30fddf6
Revert image package changes
dmcgowan Mar 22, 2019
5b45a83
add already exists image check during pull
AntaresS Mar 22, 2019
60d7eca
Support updating existing image after pull
dmcgowan Mar 22, 2019
82ceb3c
Fix swagger nonsense
dmcgowan Mar 22, 2019
3d45186
Pass test debug flag from environment
dmcgowan Mar 22, 2019
516fa02
Add load implementation using containerd import
dmcgowan Mar 25, 2019
42ed732
Update make emptyfs to use supported load format
dmcgowan Mar 25, 2019
9437023
Update output to match integration tests
dmcgowan Mar 27, 2019
9520755
image: restore(): prevent panic
kolyshkin Mar 21, 2019
1285d07
Preliminary image store migration support
kolyshkin Mar 21, 2019
ac4489b
clean up code and add comments to image_builder
AntaresS Apr 4, 2019
404133b
resolve runtime image properly for both builder and end user
AntaresS Apr 4, 2019
d74da29
Move migration to separate function
dmcgowan Apr 5, 2019
214c1f3
Fix validation
dmcgowan Apr 8, 2019
62b56f1
Update migration to use layer stores
dmcgowan Apr 10, 2019
7493e8d
Ignore not exists errors on migration
dmcgowan Apr 11, 2019
6993bef
Update dockerfile builder
dmcgowan Apr 23, 2019
0159b82
Add default tag on resolve image name
dmcgowan May 17, 2019
381eb57
Use containerd exporter
dmcgowan May 22, 2019
606ccb5
Fix integration tests
dmcgowan May 22, 2019
e39a035
Remove unnecessary layer store OS check
dmcgowan May 23, 2019
c5df768
Update containerd vendor
dmcgowan Aug 20, 2019
326c6ef
Fix containerdServiceOpt type
SamWhited Oct 3, 2019
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
12 changes: 0 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,13 @@ RUN apt-get update && apt-get install -y \
&& make PREFIX=/build/ install-criu

FROM base AS registry
# Install two versions of the registry. The first is an older version that
# only supports schema1 manifests. The second is a newer version that supports
# both. This allows integration-cli tests to cover push/pull with both schema1
# and schema2 manifests.
ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd
ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827
RUN set -x \
&& export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
&& (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") \
&& GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" \
go build -buildmode=pie -o /build/registry-v2 github.com/docker/distribution/cmd/registry \
&& case $(dpkg --print-architecture) in \
amd64|ppc64*|s390x) \
(cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1"); \
GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH"; \
go build -buildmode=pie -o /build/registry-v2-schema1 github.com/docker/distribution/cmd/registry; \
;; \
esac \
&& rm -rf "$GOPATH"


Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ DOCKER_ENVS := \
-e TEST_INTEGRATION_DIR \
-e TESTDIRS \
-e TESTFLAGS \
-e TESTDEBUG \
-e TIMEOUT \
-e VALIDATE_REPO \
-e VALIDATE_BRANCH \
Expand Down
34 changes: 11 additions & 23 deletions api/server/backend/build/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import (
"github.com/docker/docker/builder"
buildkit "github.com/docker/docker/builder/builder-next"
"github.com/docker/docker/builder/fscache"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/stringid"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
)

// ImageComponent provides an interface for working with images
type ImageComponent interface {
SquashImage(from string, to string) (string, error)
TagImageWithReference(image.ID, reference.Named) error
SquashImage(ctx context.Context, from ocispec.Descriptor, to *ocispec.Descriptor) (ocispec.Descriptor, error)
TagImageWithReference(context.Context, ocispec.Descriptor, reference.Reference) error
}

// Builder defines interface for running a build
Expand Down Expand Up @@ -75,26 +75,26 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string
return "", nil
}

var imageID = build.ImageID
var image = build.Image
if options.Squash {
if imageID, err = squashBuild(build, b.imageComponent); err != nil {
return "", err
if image, err = b.imageComponent.SquashImage(ctx, build.Image, build.FromImage); err != nil {
return "", errors.Wrap(err, "error squashing image")
}
if config.ProgressWriter.AuxFormatter != nil {
if err = config.ProgressWriter.AuxFormatter.Emit("moby.image.id", types.BuildResult{ID: imageID}); err != nil {
if err = config.ProgressWriter.AuxFormatter.Emit("moby.image.id", types.BuildResult{ID: image.Digest.String()}); err != nil {
return "", err
}
}
}

if !useBuildKit {
stdout := config.ProgressWriter.StdoutFormatter
fmt.Fprintf(stdout, "Successfully built %s\n", stringid.TruncateID(imageID))
fmt.Fprintf(stdout, "Successfully built %s\n", stringid.TruncateID(image.Digest.String()))
}
if imageID != "" {
err = tagger.TagImages(image.ID(imageID))
if image.Digest != "" {
err = tagger.TagImages(ctx, image)
}
return imageID, err
return image.Digest.String(), err
}

// PruneCache removes all cached build sources
Expand Down Expand Up @@ -133,15 +133,3 @@ func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOpti
func (b *Backend) Cancel(ctx context.Context, id string) error {
return b.buildkit.Cancel(ctx, id)
}

func squashBuild(build *builder.Result, imageComponent ImageComponent) (string, error) {
var fromID string
if build.FromImage != nil {
fromID = build.FromImage.ImageID()
}
imageID, err := imageComponent.SquashImage(build.ImageID, fromID)
if err != nil {
return "", errors.Wrap(err, "error squashing image")
}
return imageID, nil
}
7 changes: 4 additions & 3 deletions api/server/backend/build/tag.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package build // import "github.com/docker/docker/api/server/backend/build"

import (
"context"
"fmt"
"io"

"github.com/docker/distribution/reference"
"github.com/docker/docker/image"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)

Expand All @@ -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, desc ocispec.Descriptor) error {
for _, rt := range bt.repoAndTags {
if err := bt.imageComponent.TagImageWithReference(imageID, rt); err != nil {
if err := bt.imageComponent.TagImageWithReference(ctx, desc, rt); err != nil {
return err
}
fmt.Fprintf(bt.stdout, "Successfully tagged %s\n", reference.FamiliarString(rt))
Expand Down
6 changes: 3 additions & 3 deletions api/server/router/container/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type copyBackend interface {

// stateBackend includes functions to implement to provide container state lifecycle functionality.
type stateBackend interface {
ContainerCreate(config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
ContainerCreate(ctx context.Context, config types.ContainerCreateConfig) (container.ContainerCreateCreatedBody, error)
ContainerKill(name string, sig uint64) error
ContainerPause(name string) error
ContainerRename(oldName, newName string) error
Expand All @@ -54,7 +54,7 @@ type monitorBackend interface {
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
6 changes: 3 additions & 3 deletions api/server/router/container/container_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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 @@ -88,7 +88,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 @@ -505,7 +505,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
10 changes: 1 addition & 9 deletions api/server/router/distribution/backend.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package distribution // import "github.com/docker/docker/api/server/router/distribution"

import (
"context"

"github.com/docker/distribution"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
)

// Backend is all the methods that need to be implemented
// to provide image specific functionality.
type Backend interface {
GetRepository(context.Context, reference.Named, *types.AuthConfig) (distribution.Repository, bool, error)
// TODO: containerd content store or manifest returned from Named and AuthConfig
}
127 changes: 34 additions & 93 deletions api/server/router/distribution/distribution_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ import (
"net/http"
"strings"

"github.com/docker/distribution/manifest/manifestlist"
"github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/manifest/schema2"
"github.com/docker/distribution/reference"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs"
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -48,7 +44,8 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
if err != nil {
return errdefs.InvalidParameter(err)
}
namedRef, ok := ref.(reference.Named)
//namedRef, ok := ref.(reference.Named)
_, ok := ref.(reference.Named)
if !ok {
if _, ok := ref.(reference.Digested); ok {
// full image ID
Expand All @@ -57,94 +54,38 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
return errdefs.InvalidParameter(errors.Errorf("unknown image reference format: %s", image))
}

distrepo, _, err := s.backend.GetRepository(ctx, namedRef, config)
if err != nil {
return err
}
blobsrvc := distrepo.Blobs(ctx)

if canonicalRef, ok := namedRef.(reference.Canonical); !ok {
namedRef = reference.TagNameOnly(namedRef)

taggedRef, ok := namedRef.(reference.NamedTagged)
if !ok {
return errdefs.InvalidParameter(errors.Errorf("image reference not tagged: %s", image))
}

descriptor, err := distrepo.Tags(ctx).Get(ctx, taggedRef.Tag())
if err != nil {
return err
}
distributionInspect.Descriptor = v1.Descriptor{
MediaType: descriptor.MediaType,
Digest: descriptor.Digest,
Size: descriptor.Size,
}
} else {
// TODO(nishanttotla): Once manifests can be looked up as a blob, the
// descriptor should be set using blobsrvc.Stat(ctx, canonicalRef.Digest())
// instead of having to manually fill in the fields
distributionInspect.Descriptor.Digest = canonicalRef.Digest()
}

// we have a digest, so we can retrieve the manifest
mnfstsrvc, err := distrepo.Manifests(ctx)
if err != nil {
return err
}
mnfst, err := mnfstsrvc.Get(ctx, distributionInspect.Descriptor.Digest)
if err != nil {
switch err {
case reference.ErrReferenceInvalidFormat,
reference.ErrTagInvalidFormat,
reference.ErrDigestInvalidFormat,
reference.ErrNameContainsUppercase,
reference.ErrNameEmpty,
reference.ErrNameTooLong,
reference.ErrNameNotCanonical:
return errdefs.InvalidParameter(err)
}
return err
}

mediaType, payload, err := mnfst.Payload()
if err != nil {
return err
}
// update MediaType because registry might return something incorrect
distributionInspect.Descriptor.MediaType = mediaType
if distributionInspect.Descriptor.Size == 0 {
distributionInspect.Descriptor.Size = int64(len(payload))
}

// retrieve platform information depending on the type of manifest
switch mnfstObj := mnfst.(type) {
case *manifestlist.DeserializedManifestList:
for _, m := range mnfstObj.Manifests {
distributionInspect.Platforms = append(distributionInspect.Platforms, v1.Platform{
Architecture: m.Platform.Architecture,
OS: m.Platform.OS,
OSVersion: m.Platform.OSVersion,
OSFeatures: m.Platform.OSFeatures,
Variant: m.Platform.Variant,
})
}
case *schema2.DeserializedManifest:
configJSON, err := blobsrvc.Get(ctx, mnfstObj.Config.Digest)
var platform v1.Platform
if err == nil {
err := json.Unmarshal(configJSON, &platform)
if err == nil && (platform.OS != "" || platform.Architecture != "") {
distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
}
}
case *schema1.SignedManifest:
platform := v1.Platform{
Architecture: mnfstObj.Architecture,
OS: "linux",
}
distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
}
// TODO: Just pull manifest blob, done...

// TODO: Umm, get rid of this and just use images.Manifest

//// retrieve platform information depending on the type of manifest
//switch mnfstObj := mnfst.(type) {
//case *manifestlist.DeserializedManifestList:
// for _, m := range mnfstObj.Manifests {
// distributionInspect.Platforms = append(distributionInspect.Platforms, v1.Platform{
// Architecture: m.Platform.Architecture,
// OS: m.Platform.OS,
// OSVersion: m.Platform.OSVersion,
// OSFeatures: m.Platform.OSFeatures,
// Variant: m.Platform.Variant,
// })
// }
//case *schema2.DeserializedManifest:
// configJSON, err := blobsrvc.Get(ctx, mnfstObj.Config.Digest)
// var platform v1.Platform
// if err == nil {
// err := json.Unmarshal(configJSON, &platform)
// if err == nil && (platform.OS != "" || platform.Architecture != "") {
// distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
// }
// }
//case *schema1.SignedManifest:
// platform := v1.Platform{
// Architecture: mnfstObj.Architecture,
// OS: "linux",
// }
// distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
//}

return httputils.WriteJSON(w, http.StatusOK, distributionInspect)
}
16 changes: 8 additions & 8 deletions api/server/router/image/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ type Backend interface {
}

type imageBackend interface {
ImageDelete(imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
ImageHistory(imageName string) ([]*image.HistoryResponseItem, error)
Images(imageFilters filters.Args, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error)
LookupImage(name string) (*types.ImageInspect, error)
TagImage(imageName, repository, tag string) (string, error)
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error)
ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error)
Images(ctx context.Context, imageFilters filters.Args, all bool, withExtraAttrs bool) ([]*types.ImageSummary, error)
LookupImage(ctx context.Context, name string) (*types.ImageInspect, 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, platform string, 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, platform string, 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
Loading