Forrest logo
back to the docker tool

docker:tldr:55a3e

docker: Delete unused local Docker images.
$ docker image prune
try on your machine

The docker image prune command is used to remove unused or dangling images from your Docker environment.

When you build or pull images in Docker, older versions of those images may become unused over time. These unused images are often referred to as "dangling" images. The docker image prune command helps you in removing these dangling images in order to free up disk space.

Here are a few key points to understand about docker image prune:

  1. Syntax: docker image prune [OPTIONS]

  2. Options:

    • -a, --all: By default, docker image prune only removes dangling images. By including the -a flag, you can also remove all unused images, not just the dangling ones.
    • --filter: Allows you to filter images according to certain conditions. For example, you can filter based on label.
    • --force: By default, Docker asks for confirmation before removing images. The --force flag skips this confirmation step.
    • --format: This option modifies the output format of the command.
  3. Permissions: The docker image prune command requires administrator or root privileges to remove images.

It's worth noting that docker image prune does not remove any images that are currently being used by running containers. Only unused or dangling images that are not associated with any running containers will be removed.

Use this command with caution as it permanently deletes images from your Docker environment, and ensure that you have a backup or can rebuild any images that you may need in the future.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool