YouTip LogoYouTip

Docker Rmi Command

# Docker rmi Command [![Image 3: Docker Command Manual](#)Docker Command Manual](#) * * * The `docker rmi` command is used to delete one or more Docker images. The `docker rmi` command is very useful for managing locally stored images, helping users clean up images that are no longer needed and free up storage space. ### Syntax docker rmi IMAGE [IMAGE...] **Parameter Description:** * `IMAGE`: The name or ID of the image to delete. Can be an image name, image ID, or image digest. * `OPTIONS`: Optional parameters used to control the behavior of the command. Common Options: * `-a`, `--all-tags`: When specifying a repository name, delete all images under that repository. * `-f`, `--force`: Force delete the image, even if it is being used by a container. * `--help`: Print help information and exit. * `--no-prune`: Do not delete dangling parent images. * `-q`, `--quiet`: Quiet mode, do not display detailed information about deleted images. **Delete a Single Image** docker rmi ubuntu:latest Delete the image named ubuntu with the latest tag. **Delete Multiple Images** docker rmi ubuntu:latest nginx:latest Delete the images ubuntu and nginx with the latest tag. **Delete Multiple Tags of an Image** docker rmi ubuntu:latest ubuntu:18.04 Delete the latest and 18.04 tags of the ubuntu image. **Delete All Tags of an Image** docker rmi -a ubuntu Delete all images under the ubuntu repository. **Force Delete an Image** docker rmi -f ubuntu:latest Force delete the ubuntu image with the latest tag, even if it is currently in use. **Delete Dangling Images** docker rmi -d Delete all dangling images without tags. **Quiet Mode Delete All Images** docker rmi -q $(docker images -q) Use quiet mode to delete all images without displaying information about the deleted images. **Delete All Images in a Specific Repository** docker rmi -a myrepo Delete all images under the myrepo repository. **Delete an Image While Preserving Its Child Images** docker rmi --no-prune ubuntu:latest Delete the ubuntu:latest image, but preserve its child images. ### Examples View existing images: docker images Output: REPOSITORY TAG IMAGE ID CREATED SIZE my_image latest d1e1b5a3a8a9 3 days ago 128MB my_image1 latest c3a4f5a3a8b8 4 days ago 256MB my_image2 latest a9e1d3a7c9b9 5 days ago 512MB Delete an image: docker rmi my_image Output: Untagged: my_image:latest Deleted: sha256:d1e1b5a3a8a9... Delete multiple images: docker rmi my_image1 my_image2 Output: Untagged: my_image1:latest Deleted: sha256:c3a4f5a3a8b8...Untagged: my_image2:latest Deleted: sha256:a9e1d3a7c9b9... ### Common Scenarios * **Cleaning Up Unused Images**: Delete images that are no longer needed to free up storage space. * **Image Management**: Manage and maintain the local image repository, ensuring only necessary images are kept. * **Force Deletion**: Force delete images when they are being used by containers (use with caution). ### Notes * When force deleting an image (using the `-f` option), it may cause containers that depend on that image to become non-functional, so it should be used with caution. * By default, `docker rmi` will delete unused parent images. If you do not wish to do this, you can use the `--no-prune` option. The `docker rmi` command is a very important tool in Docker image management. Through this command, users can delete images that are no longer needed, free up storage space, and keep the local image repository tidy. By using appropriate options, you can flexibly manage the image deletion process. * * Docker Command Manual](#)
← Docker Save CommandDocker Push Command β†’