|
@@ -1,6 +1,7 @@
|
|
|
package images // import "github.com/docker/docker/daemon/images"
|
|
|
|
|
|
import (
|
|
|
+ "context"
|
|
|
"encoding/json"
|
|
|
"io"
|
|
|
|
|
@@ -12,7 +13,11 @@ import (
|
|
|
)
|
|
|
|
|
|
// CommitImage creates a new image from a commit config
|
|
|
-func (i *ImageService) CommitImage(c backend.CommitConfig) (image.ID, error) {
|
|
|
+func (i *ImageService) CommitImage(ctx context.Context, c backend.CommitConfig) (image.ID, error) {
|
|
|
+ if err := ctx.Err(); err != nil {
|
|
|
+ return "", err
|
|
|
+ }
|
|
|
+
|
|
|
rwTar, err := exportContainerRw(i.layerStore, c.ContainerID, c.ContainerMountLabel)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
@@ -109,7 +114,7 @@ func exportContainerRw(layerStore layer.Store, id, mountLabel string) (arch io.R
|
|
|
// - it doesn't log a container commit event
|
|
|
//
|
|
|
// This is a temporary shim. Should be removed when builder stops using commit.
|
|
|
-func (i *ImageService) CommitBuildStep(c backend.CommitConfig) (image.ID, error) {
|
|
|
+func (i *ImageService) CommitBuildStep(ctx context.Context, c backend.CommitConfig) (image.ID, error) {
|
|
|
ctr := i.containers.Get(c.ContainerID)
|
|
|
if ctr == nil {
|
|
|
// TODO: use typed error
|
|
@@ -118,5 +123,5 @@ func (i *ImageService) CommitBuildStep(c backend.CommitConfig) (image.ID, error)
|
|
|
c.ContainerMountLabel = ctr.MountLabel
|
|
|
c.ContainerOS = ctr.OS
|
|
|
c.ParentImageID = string(ctr.ImageID)
|
|
|
- return i.CommitImage(c)
|
|
|
+ return i.CommitImage(ctx, c)
|
|
|
}
|