<p>I have imported some docker images to microk8s image cache for local kubernetes deployment using,  </p>

<pre><code>microk8s.ctr -n k8s.io image import &lt;docker_image_name&gt;.tar
</code></pre>

<p>how can I remove some of the unwanted images from this cache? Is there any command for that?</p>

<p>Thanks in advance!</p>

anju
<p>If you want to delete all custom added images from the built-in library, you can do this:</p>
<pre class="lang-sh prettyprint-override"><code># get all images that start with localhost:32000, output the results into image_ls file
sudo microk8s ctr images ls name~='localhost:32000' | awk {'print $1'} &gt; image_ls 
# loop over file, remove each image
cat image_ls | while read line || [[ -n $line ]];
do
    microk8s ctr images rm $line
done;
</code></pre>
<p>Yes, I've used David Castros comment as a base, but since it did not work for Microk8s, I needed to adapt it a bit.</p>
