Search code examples
kubernetesdocker-imagemicrok8s

How to remove docker images added to microk8s image cache?


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

microk8s.ctr -n k8s.io image import <docker_image_name>.tar

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

Thanks in advance!


Solution

  • With --help you can see the that there is a remove option:

    > microk8s.ctr -n k8s.io images --help
    NAME:
       ctr images - manage images
    
    USAGE:
       ctr images command [command options] [arguments...]
    
    COMMANDS:
         check       check that an image has all content available locally
         export      export an image
         import      import images
         list, ls    list images known to containerd
         pull        pull an image from a remote
         push        push an image to a remote
         remove, rm  remove one or more images by reference
         label       set and clear labels for an image
    
    OPTIONS:
       --help, -h  show help
    

    So you can see the running containers with:

     microk8s.ctr -n k8s.io containers ls
    

    And later remove images with:

     microk8s.ctr -n k8s.io images rm "image_ref"