Skip to content

[How-To] Delete multiple images in k3d nodes (k3s containers) by name #877

Answered by iwilltry42
noamza asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @noamza , thanks for starting this discussion!
In fact, both of your commands work generally with minor tweaks:

  1. Replace double quotes with single quotes to prevent $(ctr image list -q | grep <imageName>) from being interpreted locally instead of inside the container.
$ 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:9d4f5d7968c432fbd4123f397a2d6ab666fd63d1…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@noamza
Comment options

@iwilltry42
Comment options

Answer selected by noamza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants