89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.41k stars 384 forks source link

distrobox-rm: add --image/-i for delete container image #1445

Open Boria138 opened 2 weeks ago

89luca89 commented 2 weeks ago

Thanks @Boria138 for the PR!

One problem with this is that force-deleting an image will remove also other containers using that image, for example:

image

Boria138 commented 2 weeks ago

Thanks @Boria138 for the PR!

One problem with this is that force-deleting an image will remove also other containers using that image, for example:

image

Yes, unfortunately, if you delete the image, then all the containers that use it are also deleted, but I think it's not a problem, because if a person decided to delete the image, I think he does not need the containers as well

Boria138 commented 2 weeks ago

I think you can change that distrobox rm deletes by image name, not by container name.

Boria138 commented 2 weeks ago

@89luca89 I rewrote the code so that the image name would be used, but unfortunately --filter only takes one argument at a time

89luca89 commented 1 week ago

@Boria138 tested the code, and from what I see it now is distrobox rm -i name:tag but if there is stuff using it, it errors out:

image

What I would do probably is

This should make it more intuitive to use and less error prone

what do you think?

Boria138 commented 1 week ago

@Boria138 tested the code, and from what I see it now is distrobox rm -i name:tag but if there is stuff using it, it errors out:

image

What I would do probably is

  • keep the --clean-image flag, for example
  • when rm-ing a container, check if the image is used by other containers
  • if --clean-image AND image is NOT used by other containers, then we prompt (accordingly to -Y or --force) to remove the dangling image

This should make it more intuitive to use and less error prone

what do you think?

I like this idea I will soon be implementing it