@@ -66,7 +66,7 @@ func (s *composeService) down(ctx context.Context, projectName string, options c
6666
6767 err = InReverseDependencyOrder (ctx , options .Project , func (c context.Context , service types.ServiceConfig ) error {
6868 serviceContainers := containers .filter (isService (service .Name ))
69- err := s .removeContainers (ctx , w , serviceContainers , options .Timeout )
69+ err := s .removeContainers (ctx , w , serviceContainers , options .Timeout , options . Volumes )
7070 return err
7171 })
7272 if err != nil {
@@ -75,7 +75,7 @@ func (s *composeService) down(ctx context.Context, projectName string, options c
7575
7676 orphans := containers .filter (isNotService (options .Project .ServiceNames ()... ))
7777 if options .RemoveOrphans && len (orphans ) > 0 {
78- err := s .removeContainers (ctx , w , orphans , options .Timeout )
78+ err := s .removeContainers (ctx , w , orphans , options .Timeout , false )
7979 if err != nil {
8080 return err
8181 }
@@ -215,7 +215,7 @@ func (s *composeService) stopContainers(ctx context.Context, w progress.Writer,
215215 return eg .Wait ()
216216}
217217
218- func (s * composeService ) removeContainers (ctx context.Context , w progress.Writer , containers []moby.Container , timeout * time.Duration ) error {
218+ func (s * composeService ) removeContainers (ctx context.Context , w progress.Writer , containers []moby.Container , timeout * time.Duration , volumes bool ) error {
219219 eg , _ := errgroup .WithContext (ctx )
220220 for _ , container := range containers {
221221 toDelete := container
@@ -228,7 +228,10 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer
228228 return err
229229 }
230230 w .Event (progress .RemovingEvent (eventName ))
231- err = s .apiClient .ContainerRemove (ctx , toDelete .ID , moby.ContainerRemoveOptions {Force : true })
231+ err = s .apiClient .ContainerRemove (ctx , toDelete .ID , moby.ContainerRemoveOptions {
232+ Force : true ,
233+ RemoveVolumes : volumes ,
234+ })
232235 if err != nil {
233236 w .Event (progress .ErrorMessageEvent (eventName , "Error while Removing" ))
234237 return err
0 commit comments