User Tools

Site Tools


docker:remove_an_image

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker:remove_an_image [2020/04/15 22:10] – created peterdocker:remove_an_image [2020/05/13 08:45] (current) – removed peter
Line 1: Line 1:
-====== Docker - Remove an image ====== 
- 
-===== Find the image ===== 
- 
-<code bash> 
-docker images 
-</code> 
- 
-returns: 
- 
-<code bash> 
-REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE 
-ubuntu              16.10               df4ba6fcd70e        36 hours ago        100.2 MB 
-ubuntu              16.04               f753707788c5        36 hours ago        127.2 MB 
-ubuntu              latest              f753707788c5        36 hours ago        127.2 MB 
-hello-world         latest              c54a2cc56cbb        3 months ago        1.848 kB 
-docker/whalesay     latest              6b362a9f73eb        16 months ago       247 MB 
-</code> 
- 
----- 
- 
-Now remove an image 
- 
-<code bash> 
-docker rmi image_name 
-</code> 
- 
-Seeing all created containers is as simple as **docker ps -a**. 
- 
-To remove all existing containers (not images!) run: 
- 
-<code bash> 
-docker rm $(docker ps -aq) 
-</code> 
- 
----- 
- 
-===== Removing images according to a pattern ===== 
- 
-You can find all the images that match a pattern using a combination of **docker images** and **grep**. 
- 
-Once you're satisfied, you can delete them by using **awk** to pass the IDs to **docker rmi**. 
- 
-<WRAP info> 
-**NOTE:**  These utilities are not supplied by Docker and are not necessarily available on all systems: 
-</WRAP> 
- 
- 
-To find the images: 
- 
-<code bash> 
-docker ps -a |  grep "pattern" 
-</code> 
- 
- 
-To remove the images: 
- 
-<code bash> 
-docker images | grep "pattern" | awk '{print $1}' | xargs docker rm 
-</code> 
- 
----- 
- 
-===== Remove all images ===== 
- 
-All the Docker images on a system can be listed by adding -a to the **docker images** command. 
- 
-Once you're sure you want to delete them all, you can add the -q flag to pass the Image ID to **docker rmi**: 
- 
-To list the images: 
- 
-<code bash> 
-docker images -a 
-</code> 
- 
- 
-To remove the images: 
- 
-<code bash> 
-docker rmi $(docker images -a -q) 
-</code> 
  
docker/remove_an_image.1586988630.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki