浏览代码

detect conflict removing volume/image and warn user

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 2 年之前
父节点
当前提交
c7afc6188b
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      pkg/compose/down.go

+ 8 - 0
pkg/compose/down.go

@@ -252,6 +252,10 @@ func (s *composeService) removeImage(ctx context.Context, image string, w progre
 		w.Event(progress.NewEvent(id, progress.Done, "Removed"))
 		return nil
 	}
+	if errdefs.IsConflict(err) {
+		w.Event(progress.NewEvent(id, progress.Warning, "Resource is still in use"))
+		return nil
+	}
 	if errdefs.IsNotFound(err) {
 		w.Event(progress.NewEvent(id, progress.Done, "Warning: No resource found to remove"))
 		return nil
@@ -267,6 +271,10 @@ func (s *composeService) removeVolume(ctx context.Context, id string, w progress
 		w.Event(progress.NewEvent(resource, progress.Done, "Removed"))
 		return nil
 	}
+	if errdefs.IsConflict(err) {
+		w.Event(progress.NewEvent(resource, progress.Warning, "Resource is still in use"))
+		return nil
+	}
 	if errdefs.IsNotFound(err) {
 		w.Event(progress.NewEvent(resource, progress.Done, "Warning: No resource found to remove"))
 		return nil