Docker
To delete images in Docker, you can use thedocker rmi
or docker image rm
commands. Here are the steps:
-
List the Docker images: Before you can delete an image, you need to know its ID or name. You can list all Docker images on your system with the
docker images
command:This will display a list of all Docker images along with their repository name, tag, image ID, creation date, and size. -
Delete a Docker image: Once you have the image ID or name, you can delete the image. Replace
<image-id>
with the ID of the image you want to delete:Or, if you prefer to use the image name and tag, replace<image-name>:<tag>
with the name and tag of the image you want to delete: -
Delete all Docker images: If you want to delete all Docker images, you can use the following command:
This command uses
docker images -q
to list all image IDs and then passes them todocker rmi
to delete them.
containerd
To delete images in containerd, you can use thectr
command-line interface. Here are the steps:
-
List the containerd images: Before you can delete an image, you need to know its ID or name. You can list all containerd images on your system with the
ctr images ls
command:This will display a list of all containerd images along with their name and size. -
Delete a containerd image: Once you have the image ID or name, you can delete the image. Replace
<image-name>
with the name of the image you want to delete: -
Delete all containerd images: If you want to delete all containerd images, you can use the following command:
This command uses
ctr images ls -q
to list all image names and then passes them toctr images rm
to delete them.