Listing and Removing Docker Images for better understanding
Docker image is an important part of the whole docker’s architecture, as it is the main source from which our containers are going to be created with the help of docker, therefore they are necessary.
Listing Docker Images
Here, with the help of few commands, we are able to see available docker images in our system (locally).
Via running the command below, we can see that we have two available images in our local library or on our local system:
List docker image with “full details”
sudo docker image ls
List docker image with only “Image ID’s”
We can also only see the “Images ID’s” of images and avoid the other details by using the following command.
sudo docker image ls -q
Removing Docker Images
Again, with the help of following commands, it becomes easy and handy to remove docker images.
Remove docker image using “Image name”
Simply running the command below, we can see that we are able to delete our locally present “alpine” image.
sudo docker image rm alpine
Now, when we try to see the available images on our system, from the image below it is seen that only the “Ubuntu” image is left on our system.
Remove docker image using “Image ID”
We can also remove by only providing the “Image ID’s” of available images.
After removing the “Ubuntu” image using its “Image ID“, we can see from below that there are “0 Images” available in our system, at the
Remove all docker images at once with one command
Currently, we can see that we have following two images available in our system:
Now, by running the combination or following commands, we can delete or remove all the available images in our system, at once.
sudo docker image rm $(sudo docker image ls -q)
After executing the above command, we can confirm that we are able to remove all the images present in our system at once, as shown below.
Conclusion “Listing and Removing Docker Images”
We have learned about checking the docker images and then if needed how to remove them.