Skip to main content

Docker

To delete images in Docker, you can use the docker rmi or docker image rm commands. Here are the steps:
  1. 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.
  2. 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:
  3. 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 to docker rmi to delete them.
Please note that you cannot delete an image that is being used by an existing container. You would first need to delete or stop the container that is using the image.

containerd

To delete images in containerd, you can use the ctr command-line interface. Here are the steps:
  1. 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.
  2. 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:
  3. 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 to ctr images rm to delete them.
Please note that you cannot delete an image that is being used by an existing container. You would first need to delete or stop the container that is using the image.