1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43939 from thaJeztah/containerd_contexts_step1

containerd integration: imageservice: add contexts to various methods (step 1)
This commit is contained in:
Sebastiaan van Stijn 2022-09-07 19:31:27 +02:00 committed by GitHub
commit 105eee7e24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 65 additions and 33 deletions

View file

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

View file

@ -193,7 +193,7 @@ func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
} }
func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error { func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
img, err := ir.backend.GetImage(vars["name"], opts.GetImageOpts{}) img, err := ir.backend.GetImage(ctx, vars["name"], opts.GetImageOpts{})
if err != nil { if err != nil {
return err return err
} }

View file

@ -77,5 +77,5 @@ type VolumeBackend interface {
type ImageBackend interface { type ImageBackend interface {
PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error PullImage(ctx context.Context, image, tag string, platform *specs.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
GetRepository(context.Context, reference.Named, *registry.AuthConfig) (distribution.Repository, error) GetRepository(context.Context, reference.Named, *registry.AuthConfig) (distribution.Repository, error)
GetImage(refOrID string, options opts.GetImageOpts) (*image.Image, error) GetImage(ctx context.Context, refOrID string, options opts.GetImageOpts) (*image.Image, error)
} }

View file

@ -76,7 +76,10 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
named, err := reference.ParseNormalizedNamed(spec.Image) named, err := reference.ParseNormalizedNamed(spec.Image)
if err == nil { if err == nil {
if _, ok := named.(reference.Canonical); ok { if _, ok := named.(reference.Canonical); ok {
_, err := c.imageBackend.GetImage(spec.Image, imagetypes.GetImageOpts{}) _, err := c.imageBackend.GetImage(ctx, spec.Image, imagetypes.GetImageOpts{})
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
}
if err == nil { if err == nil {
return nil return nil
} }

View file

@ -1,11 +1,13 @@
package containerd package containerd
import ( import (
"context"
imagetype "github.com/docker/docker/api/types/image" imagetype "github.com/docker/docker/api/types/image"
"github.com/docker/docker/image" "github.com/docker/docker/image"
) )
// GetImage returns an image corresponding to the image referred to by refOrID. // GetImage returns an image corresponding to the image referred to by refOrID.
func (i *ImageService) GetImage(refOrID string, options imagetype.GetImageOpts) (retImg *image.Image, retErr error) { func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (retImg *image.Image, retErr error) {
panic("not implemented") panic("not implemented")
} }

View file

@ -1,6 +1,7 @@
package daemon // import "github.com/docker/docker/daemon" package daemon // import "github.com/docker/docker/daemon"
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"runtime" "runtime"
@ -58,6 +59,7 @@ func (daemon *Daemon) ContainerCreateIgnoreImagesArgsEscaped(params types.Contai
} }
func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateResponse, error) { func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateResponse, error) {
ctx := context.TODO()
start := time.Now() start := time.Now()
if opts.params.Config == nil { if opts.params.Config == nil {
return containertypes.CreateResponse{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container")) return containertypes.CreateResponse{}, errdefs.InvalidParameter(errors.New("Config cannot be empty in order to create a container"))
@ -69,7 +71,11 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateRes
} }
if opts.params.Platform == nil && opts.params.Config.Image != "" { if opts.params.Platform == nil && opts.params.Config.Image != "" {
if img, _ := daemon.imageService.GetImage(opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform}); img != nil { img, err := daemon.imageService.GetImage(ctx, opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform})
if err != nil {
return containertypes.CreateResponse{}, err
}
if img != nil {
p := maximumSpec() p := maximumSpec()
imgPlat := v1.Platform{ imgPlat := v1.Platform{
OS: img.OS, OS: img.OS,
@ -111,6 +117,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.CreateRes
// Create creates a new container from the given configuration with a given name. // Create creates a new container from the given configuration with a given name.
func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr error) { func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr error) {
ctx := context.TODO()
var ( var (
ctr *container.Container ctr *container.Container
img *image.Image img *image.Image
@ -120,7 +127,7 @@ func (daemon *Daemon) create(opts createOpts) (retC *container.Container, retErr
) )
if opts.params.Config.Image != "" { if opts.params.Config.Image != "" {
img, err = daemon.imageService.GetImage(opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform}) img, err = daemon.imageService.GetImage(ctx, opts.params.Config.Image, imagetypes.GetImageOpts{Platform: opts.params.Platform})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -40,7 +40,7 @@ type ImageService interface {
ImportImage(src string, repository string, platform *v1.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error ImportImage(src string, repository string, platform *v1.Platform, tag string, msg string, inConfig io.ReadCloser, outStream io.Writer, changes []string) error
TagImage(imageName, repository, tag string) (string, error) TagImage(imageName, repository, tag string) (string, error)
TagImageWithReference(imageID image.ID, newTag reference.Named) error TagImageWithReference(imageID image.ID, newTag reference.Named) error
GetImage(refOrID string, options imagetype.GetImageOpts) (*image.Image, error) GetImage(ctx context.Context, refOrID string, options imagetype.GetImageOpts) (*image.Image, error)
ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error) ImageHistory(name string) ([]*imagetype.HistoryResponseItem, error)
CommitImage(c backend.CommitConfig) (image.ID, error) CommitImage(c backend.CommitConfig) (image.ID, error)
SquashImage(id, parent string) (string, error) SquashImage(id, parent string) (string, error)

View file

@ -1,6 +1,8 @@
package images // import "github.com/docker/docker/daemon/images" package images // import "github.com/docker/docker/daemon/images"
import ( import (
"context"
imagetypes "github.com/docker/docker/api/types/image" imagetypes "github.com/docker/docker/api/types/image"
"github.com/docker/docker/builder" "github.com/docker/docker/builder"
"github.com/docker/docker/image/cache" "github.com/docker/docker/image/cache"
@ -9,6 +11,7 @@ import (
// MakeImageCache creates a stateful image cache. // MakeImageCache creates a stateful image cache.
func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache { func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
ctx := context.TODO()
if len(sourceRefs) == 0 { if len(sourceRefs) == 0 {
return cache.NewLocal(i.imageStore) return cache.NewLocal(i.imageStore)
} }
@ -16,7 +19,7 @@ func (i *ImageService) MakeImageCache(sourceRefs []string) builder.ImageCache {
cache := cache.New(i.imageStore) cache := cache.New(i.imageStore)
for _, ref := range sourceRefs { for _, ref := range sourceRefs {
img, err := i.GetImage(ref, imagetypes.GetImageOpts{}) img, err := i.GetImage(ctx, ref, imagetypes.GetImageOpts{})
if err != nil { if err != nil {
logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err) logrus.Warnf("Could not look up %s for cache resolution, skipping: %+v", ref, err)
continue continue

View file

@ -45,14 +45,13 @@ type manifest struct {
Config specs.Descriptor `json:"config"` Config specs.Descriptor `json:"config"`
} }
func (i *ImageService) manifestMatchesPlatform(img *image.Image, platform specs.Platform) bool { func (i *ImageService) manifestMatchesPlatform(ctx context.Context, img *image.Image, platform specs.Platform) (bool, error) {
ctx := context.TODO()
logger := logrus.WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform)) logger := logrus.WithField("image", img.ID).WithField("desiredPlatform", platforms.Format(platform))
ls, leaseErr := i.leases.ListResources(context.TODO(), leases.Lease{ID: imageKey(img.ID().Digest())}) ls, leaseErr := i.leases.ListResources(ctx, leases.Lease{ID: imageKey(img.ID().Digest())})
if leaseErr != nil { if leaseErr != nil {
logger.WithError(leaseErr).Error("Error looking up image leases") logger.WithError(leaseErr).Error("Error looking up image leases")
return false return false, leaseErr
} }
// Note we are comparing against manifest lists here, which we expect to always have a CPU variant set (where applicable). // Note we are comparing against manifest lists here, which we expect to always have a CPU variant set (where applicable).
@ -138,18 +137,18 @@ func (i *ImageService) manifestMatchesPlatform(img *image.Image, platform specs.
if m.Config.Digest == img.ID().Digest() { if m.Config.Digest == img.ID().Digest() {
logger.WithField("manifestDigest", md.Digest).Debug("Found matching manifest for image") logger.WithField("manifestDigest", md.Digest).Debug("Found matching manifest for image")
return true return true, nil
} }
logger.WithField("otherDigest", md.Digest).Debug("Skipping non-matching manifest") logger.WithField("otherDigest", md.Digest).Debug("Skipping non-matching manifest")
} }
} }
return false return false, nil
} }
// GetImage returns an image corresponding to the image referred to by refOrID. // GetImage returns an image corresponding to the image referred to by refOrID.
func (i *ImageService) GetImage(refOrID string, options imagetypes.GetImageOpts) (retImg *image.Image, retErr error) { func (i *ImageService) GetImage(ctx context.Context, refOrID string, options imagetypes.GetImageOpts) (retImg *image.Image, retErr error) {
defer func() { defer func() {
if retErr != nil || retImg == nil || options.Platform == nil { if retErr != nil || retImg == nil || options.Platform == nil {
return return
@ -168,7 +167,9 @@ func (i *ImageService) GetImage(refOrID string, options imagetypes.GetImageOpts)
} }
// In some cases the image config can actually be wrong (e.g. classic `docker build` may not handle `--platform` correctly) // In some cases the image config can actually be wrong (e.g. classic `docker build` may not handle `--platform` correctly)
// So we'll look up the manifest list that coresponds to this imaage to check if at least the manifest list says it is the correct image. // So we'll look up the manifest list that coresponds to this imaage to check if at least the manifest list says it is the correct image.
if i.manifestMatchesPlatform(retImg, p) { var matches bool
matches, retErr = i.manifestMatchesPlatform(ctx, retImg, p)
if matches || retErr != nil {
return return
} }

View file

@ -168,7 +168,7 @@ func (i *ImageService) pullForBuilder(ctx context.Context, name string, authConf
return nil, err return nil, err
} }
img, err := i.GetImage(name, imagetypes.GetImageOpts{Platform: platform}) img, err := i.GetImage(ctx, name, imagetypes.GetImageOpts{Platform: platform})
if errdefs.IsNotFound(err) && img != nil && platform != nil { if errdefs.IsNotFound(err) && img != nil && platform != nil {
imgPlat := specs.Platform{ imgPlat := specs.Platform{
OS: img.OS, OS: img.OS,
@ -212,11 +212,13 @@ func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID s
} }
if opts.PullOption != backend.PullOptionForcePull { if opts.PullOption != backend.PullOptionForcePull {
img, err := i.GetImage(refOrID, imagetypes.GetImageOpts{Platform: opts.Platform}) img, err := i.GetImage(ctx, refOrID, imagetypes.GetImageOpts{Platform: opts.Platform})
if err != nil && opts.PullOption == backend.PullOptionNoPull { if err != nil && opts.PullOption == backend.PullOptionNoPull {
return nil, nil, err return nil, nil, err
} }
// TODO: shouldn't we error out if error is different from "not found" ? if err != nil && !errdefs.IsNotFound(err) {
return nil, nil, err
}
if img != nil { if img != nil {
if !system.IsOSSupported(img.OperatingSystem()) { if !system.IsOSSupported(img.OperatingSystem()) {
return nil, nil, system.ErrNotSupportedOperatingSystem return nil, nil, system.ErrNotSupportedOperatingSystem

View file

@ -64,7 +64,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
start := time.Now() start := time.Now()
records := []types.ImageDeleteResponseItem{} records := []types.ImageDeleteResponseItem{}
img, err := i.GetImage(imageRef, imagetypes.GetImageOpts{}) img, err := i.GetImage(ctx, imageRef, imagetypes.GetImageOpts{})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -1,6 +1,8 @@
package images // import "github.com/docker/docker/daemon/images" package images // import "github.com/docker/docker/daemon/images"
import ( import (
"context"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
imagetypes "github.com/docker/docker/api/types/image" imagetypes "github.com/docker/docker/api/types/image"
) )
@ -12,7 +14,8 @@ func (i *ImageService) LogImageEvent(imageID, refName, action string) {
// LogImageEventWithAttributes generates an event related to an image with specific given attributes. // LogImageEventWithAttributes generates an event related to an image with specific given attributes.
func (i *ImageService) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) { func (i *ImageService) LogImageEventWithAttributes(imageID, refName, action string, attributes map[string]string) {
img, err := i.GetImage(imageID, imagetypes.GetImageOpts{}) ctx := context.TODO()
img, err := i.GetImage(ctx, imageID, imagetypes.GetImageOpts{})
if err == nil && img.Config != nil { if err == nil && img.Config != nil {
// image has not been removed yet. // image has not been removed yet.
// it could be missing if the event is `delete`. // it could be missing if the event is `delete`.

View file

@ -1,6 +1,7 @@
package images // import "github.com/docker/docker/daemon/images" package images // import "github.com/docker/docker/daemon/images"
import ( import (
"context"
"fmt" "fmt"
"time" "time"
@ -12,8 +13,9 @@ import (
// ImageHistory returns a slice of ImageHistory structures for the specified image // ImageHistory returns a slice of ImageHistory structures for the specified image
// name by walking the image lineage. // name by walking the image lineage.
func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error) { func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem, error) {
ctx := context.TODO()
start := time.Now() start := time.Now()
img, err := i.GetImage(name, image.GetImageOpts{}) img, err := i.GetImage(ctx, name, image.GetImageOpts{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -69,7 +71,7 @@ func (i *ImageService) ImageHistory(name string) ([]*image.HistoryResponseItem,
if id == "" { if id == "" {
break break
} }
histImg, err = i.GetImage(id.String(), image.GetImageOpts{}) histImg, err = i.GetImage(ctx, id.String(), image.GetImageOpts{})
if err != nil { if err != nil {
break break
} }

View file

@ -31,7 +31,7 @@ func (r byCreated) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created } func (r byCreated) Less(i, j int) bool { return r[i].Created < r[j].Created }
// Images returns a filtered list of images. // Images returns a filtered list of images.
func (i *ImageService) Images(_ context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error) { func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error) {
if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil { if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
return nil, err return nil, err
} }
@ -50,7 +50,7 @@ func (i *ImageService) Images(_ context.Context, opts types.ImageListOptions) ([
err error err error
) )
err = opts.Filters.WalkValues("before", func(value string) error { err = opts.Filters.WalkValues("before", func(value string) error {
beforeFilter, err = i.GetImage(value, imagetypes.GetImageOpts{}) beforeFilter, err = i.GetImage(ctx, value, imagetypes.GetImageOpts{})
return err return err
}) })
if err != nil { if err != nil {
@ -58,7 +58,7 @@ func (i *ImageService) Images(_ context.Context, opts types.ImageListOptions) ([
} }
err = opts.Filters.WalkValues("since", func(value string) error { err = opts.Filters.WalkValues("since", func(value string) error {
sinceFilter, err = i.GetImage(value, imagetypes.GetImageOpts{}) sinceFilter, err = i.GetImage(ctx, value, imagetypes.GetImageOpts{})
return err return err
}) })
if err != nil { if err != nil {

View file

@ -64,7 +64,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag string, platfor
// we allow the image to have a non-matching architecture. The code // we allow the image to have a non-matching architecture. The code
// below checks for this situation, and returns a warning to the client, // below checks for this situation, and returns a warning to the client,
// as well as logging it to the daemon logs. // as well as logging it to the daemon logs.
img, err := i.GetImage(image, imagetypes.GetImageOpts{Platform: platform}) img, err := i.GetImage(ctx, image, imagetypes.GetImageOpts{Platform: platform})
// Note that this is a special case where GetImage returns both an image // Note that this is a special case where GetImage returns both an image
// and an error: https://github.com/docker/docker/blob/v20.10.7/daemon/images/image.go#L175-L183 // and an error: https://github.com/docker/docker/blob/v20.10.7/daemon/images/image.go#L175-L183
@ -72,6 +72,8 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag string, platfor
po := streamformatter.NewJSONProgressOutput(outStream, false) po := streamformatter.NewJSONProgressOutput(outStream, false)
progress.Messagef(po, "", `WARNING: %s`, err.Error()) progress.Messagef(po, "", `WARNING: %s`, err.Error())
logrus.WithError(err).WithField("image", image).Warn("ignoring platform mismatch on single-arch image") logrus.WithError(err).WithField("image", image).Warn("ignoring platform mismatch on single-arch image")
} else if err != nil {
return err
} }
} }

View file

@ -1,6 +1,8 @@
package images // import "github.com/docker/docker/daemon/images" package images // import "github.com/docker/docker/daemon/images"
import ( import (
"context"
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
imagetypes "github.com/docker/docker/api/types/image" imagetypes "github.com/docker/docker/api/types/image"
"github.com/docker/docker/image" "github.com/docker/docker/image"
@ -9,7 +11,8 @@ import (
// TagImage creates the tag specified by newTag, pointing to the image named // TagImage creates the tag specified by newTag, pointing to the image named
// imageName (alternatively, imageName can also be an image ID). // imageName (alternatively, imageName can also be an image ID).
func (i *ImageService) TagImage(imageName, repository, tag string) (string, error) { func (i *ImageService) TagImage(imageName, repository, tag string) (string, error) {
img, err := i.GetImage(imageName, imagetypes.GetImageOpts{}) ctx := context.TODO()
img, err := i.GetImage(ctx, imageName, imagetypes.GetImageOpts{})
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -1,6 +1,7 @@
package daemon // import "github.com/docker/docker/daemon" package daemon // import "github.com/docker/docker/daemon"
import ( import (
"context"
"fmt" "fmt"
"sort" "sort"
"strconv" "strconv"
@ -243,6 +244,7 @@ func (daemon *Daemon) reducePsContainer(container *container.Snapshot, filter *l
// foldFilter generates the container filter based on the user's filtering options. // foldFilter generates the container filter based on the user's filtering options.
func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerListOptions) (*listContext, error) { func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerListOptions) (*listContext, error) {
ctx := context.TODO()
psFilters := config.Filters psFilters := config.Filters
var filtExited []int var filtExited []int
@ -318,7 +320,7 @@ func (daemon *Daemon) foldFilter(view container.View, config *types.ContainerLis
if psFilters.Contains("ancestor") { if psFilters.Contains("ancestor") {
ancestorFilter = true ancestorFilter = true
psFilters.WalkValues("ancestor", func(ancestor string) error { psFilters.WalkValues("ancestor", func(ancestor string) error {
img, err := daemon.imageService.GetImage(ancestor, imagetypes.GetImageOpts{}) img, err := daemon.imageService.GetImage(ctx, ancestor, imagetypes.GetImageOpts{})
if err != nil { if err != nil {
logrus.Warnf("Error while looking up for image %v", ancestor) logrus.Warnf("Error while looking up for image %v", ancestor)
return nil return nil
@ -579,10 +581,11 @@ func includeContainerInList(container *container.Snapshot, filter *listContext)
// refreshImage checks if the Image ref still points to the correct ID, and updates the ref to the actual ID when it doesn't // refreshImage checks if the Image ref still points to the correct ID, and updates the ref to the actual ID when it doesn't
func (daemon *Daemon) refreshImage(s *container.Snapshot, filter *listContext) (*types.Container, error) { func (daemon *Daemon) refreshImage(s *container.Snapshot, filter *listContext) (*types.Container, error) {
ctx := context.TODO()
c := s.Container c := s.Container
tmpImage := s.Image // keep the original ref if still valid (hasn't changed) tmpImage := s.Image // keep the original ref if still valid (hasn't changed)
if tmpImage != s.ImageID { if tmpImage != s.ImageID {
img, err := daemon.imageService.GetImage(tmpImage, imagetypes.GetImageOpts{}) img, err := daemon.imageService.GetImage(ctx, tmpImage, imagetypes.GetImageOpts{})
if _, isDNE := err.(images.ErrImageDoesNotExist); err != nil && !isDNE { if _, isDNE := err.(images.ErrImageDoesNotExist); err != nil && !isDNE {
return nil, err return nil, err
} }

View file

@ -1,6 +1,7 @@
package daemon // import "github.com/docker/docker/daemon" package daemon // import "github.com/docker/docker/daemon"
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"
@ -26,8 +27,8 @@ const (
) )
func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) {
ctx := context.TODO()
img, err := daemon.imageService.GetImage(string(c.ImageID), imagetypes.GetImageOpts{}) img, err := daemon.imageService.GetImage(ctx, string(c.ImageID), imagetypes.GetImageOpts{})
if err != nil { if err != nil {
return nil, err return nil, err
} }