diff --git a/services/containers/service.go b/services/containers/service.go index 428de476d..c5322f874 100644 --- a/services/containers/service.go +++ b/services/containers/service.go @@ -10,6 +10,7 @@ import ( "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/plugin" "github.com/golang/protobuf/ptypes/empty" + "github.com/pkg/errors" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -160,6 +161,10 @@ func (s *Service) Delete(ctx context.Context, req *api.DeleteContainerRequest) ( return &empty.Empty{}, err } + if err := s.db.GarbageCollect(ctx); err != nil { + return &empty.Empty{}, errdefs.ToGRPC(errors.Wrap(err, "garbage collection failed")) + } + return &empty.Empty{}, nil } diff --git a/services/images/service.go b/services/images/service.go index 6c5d3b685..fa8a00aae 100644 --- a/services/images/service.go +++ b/services/images/service.go @@ -10,6 +10,7 @@ import ( "github.com/containerd/containerd/metadata" "github.com/containerd/containerd/plugin" "github.com/golang/protobuf/ptypes/empty" + "github.com/pkg/errors" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -161,6 +162,10 @@ func (s *Service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) return nil, err } + if err := s.db.GarbageCollect(ctx); err != nil { + return nil, errdefs.ToGRPC(errors.Wrap(err, "garbage collection failed")) + } + return &empty.Empty{}, nil }