docker:remove_an_image
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docker:remove_an_image [2020/04/15 22:10] – created peter | docker: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 | ||
- | </ | ||
- | |||
- | returns: | ||
- | |||
- | <code bash> | ||
- | REPOSITORY | ||
- | ubuntu | ||
- | ubuntu | ||
- | ubuntu | ||
- | hello-world | ||
- | docker/ | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | Now remove an image | ||
- | |||
- | <code bash> | ||
- | docker rmi image_name | ||
- | </ | ||
- | |||
- | 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) | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== 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: | ||
- | </ | ||
- | |||
- | |||
- | To find the images: | ||
- | |||
- | <code bash> | ||
- | docker ps -a | grep " | ||
- | </ | ||
- | |||
- | |||
- | To remove the images: | ||
- | |||
- | <code bash> | ||
- | docker images | grep " | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== 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 | ||
- | </ | ||
- | |||
- | |||
- | To remove the images: | ||
- | |||
- | <code bash> | ||
- | docker rmi $(docker images -a -q) | ||
- | </ | ||
docker/remove_an_image.1586988630.txt.gz · Last modified: 2020/07/15 09:30 (external edit)