[How-To] Delete multiple images in k3d nodes (k3s containers) by name #877
-
I am trying to delete multiple images at once based on their name, I was hoping for something like
but this doesn't work. Any ideas? Note: my environment apparently doesn't contain xargs so
also doesn't work |
Beta Was this translation helpful? Give feedback.
Answered by
iwilltry42
Dec 7, 2021
Replies: 1 comment 2 replies
-
Hi @noamza , thanks for starting this discussion!
$ docker exec k3d-t-server-0 sh -c "ctr image list -q | grep coredns"
docker.io/rancher/coredns-coredns:1.8.3
docker.io/rancher/coredns-coredns@sha256:9d4f5d7968c432fbd4123f397a2d6ab666fd63d13d510d9728d717c3e002dc72
$ docker exec k3d-t-server-0 sh -c 'ctr image rm $(ctr image list -q | grep coredns)'
docker.io/rancher/coredns-coredns:1.8.3
docker.io/rancher/coredns-coredns@sha256:9d4f5d7968c432fbd4123f397a2d6ab666fd63d13d510d9728d717c3e002dc72
$ docker exec k3d-t-server-0 sh -c "ctr image list -q | grep coredns"
$ docker exec k3d-t-server-0 sh -c "ctr image list -q | grep klipper"
docker.io/rancher/klipper-helm:v0.6.6-build20211022
docker.io/rancher/klipper-helm@sha256:961459b8641aa77dae39c96ba8efba88805a8949dcaafa131d1aecc1510128bf
docker.io/rancher/klipper-lb:v0.3.4
docker.io/rancher/klipper-lb@sha256:d5ec8350ee1a80ec783effe95a2fefae371d1498ac04865cb6024499882f291c
$ docker exec k3d-t-server-0 sh -c "ctr image list -q | grep klipper | busybox xargs ctr image rm"
docker.io/rancher/klipper-helm:v0.6.6-build20211022
docker.io/rancher/klipper-helm@sha256:961459b8641aa77dae39c96ba8efba88805a8949dcaafa131d1aecc1510128bf
docker.io/rancher/klipper-lb:v0.3.4
docker.io/rancher/klipper-lb@sha256:d5ec8350ee1a80ec783effe95a2fefae371d1498ac04865cb6024499882f291c
$ docker exec k3d-t-server-0 sh -c "ctr image list -q | grep klipper" |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
noamza
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @noamza , thanks for starting this discussion!
In fact, both of your commands work generally with minor tweaks:
$(ctr image list -q | grep <imageName>)
from being interpreted locally instead of inside the container.