Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Managing Image Storage and Cleanup | Working with Docker Images
Docker Essentials

bookManaging Image Storage and Cleanup

Listing Docker Images

When you work with Docker, you often accumulate many images over time. Keeping your system organized and efficient means understanding how to list, inspect, and manage these images.

To see which images are currently stored on your system, use the following command:

docker images

This command displays a table with the following columns:

  • REPOSITORY: Shows the name of the image;
  • TAG: Represents a version or variant, such as latest;
  • IMAGE ID: Unique identifier for each image, used when removing or referencing images;
  • CREATED: Indicates when the image was created;
  • SIZE: Helps you identify which images are consuming the most disk space.

Understanding these columns allows you to quickly assess your stored images and make informed decisions about managing disk space and image usage.

Removing Images and Containers

Over time, unused images and stopped containers can take up a significant amount of storage.

  • To remove an image you no longer need, use the following command:

    docker rmi IMAGE_ID
    

    Replace IMAGE_ID with the actual identifier of the image you want to delete;

  • If you attempt to remove an image that is still being used by a container, Docker will prevent the removal to avoid breaking running or stopped containers;

  • To resolve this, first remove the associated container using:

    docker rm CONTAINER_ID
    

    Replace CONTAINER_ID with the identifier of the stopped container;

  • Removing unused images and containers helps you reclaim disk space and keeps your Docker environment tidy.

Cleaning Up with docker system prune

For a more comprehensive cleanup, Docker provides the docker system prune command.

  • Removes all stopped containers;
  • Deletes unused networks;
  • Cleans up dangling images (images not tagged or referenced by any container);
  • Optionally removes unused volumes.

Running docker system prune prompts you for confirmation before deleting resources, allowing you to review what will be removed. This command is a powerful way to free up space, but be cautiousβ€”once resources are pruned, they cannot be recovered. Use this command regularly to prevent your system from becoming cluttered with obsolete Docker resources.

question mark

Which command lists all Docker images currently stored on your system?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 5

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 7.14

bookManaging Image Storage and Cleanup

Swipe to show menu

Listing Docker Images

When you work with Docker, you often accumulate many images over time. Keeping your system organized and efficient means understanding how to list, inspect, and manage these images.

To see which images are currently stored on your system, use the following command:

docker images

This command displays a table with the following columns:

  • REPOSITORY: Shows the name of the image;
  • TAG: Represents a version or variant, such as latest;
  • IMAGE ID: Unique identifier for each image, used when removing or referencing images;
  • CREATED: Indicates when the image was created;
  • SIZE: Helps you identify which images are consuming the most disk space.

Understanding these columns allows you to quickly assess your stored images and make informed decisions about managing disk space and image usage.

Removing Images and Containers

Over time, unused images and stopped containers can take up a significant amount of storage.

  • To remove an image you no longer need, use the following command:

    docker rmi IMAGE_ID
    

    Replace IMAGE_ID with the actual identifier of the image you want to delete;

  • If you attempt to remove an image that is still being used by a container, Docker will prevent the removal to avoid breaking running or stopped containers;

  • To resolve this, first remove the associated container using:

    docker rm CONTAINER_ID
    

    Replace CONTAINER_ID with the identifier of the stopped container;

  • Removing unused images and containers helps you reclaim disk space and keeps your Docker environment tidy.

Cleaning Up with docker system prune

For a more comprehensive cleanup, Docker provides the docker system prune command.

  • Removes all stopped containers;
  • Deletes unused networks;
  • Cleans up dangling images (images not tagged or referenced by any container);
  • Optionally removes unused volumes.

Running docker system prune prompts you for confirmation before deleting resources, allowing you to review what will be removed. This command is a powerful way to free up space, but be cautiousβ€”once resources are pruned, they cannot be recovered. Use this command regularly to prevent your system from becoming cluttered with obsolete Docker resources.

question mark

Which command lists all Docker images currently stored on your system?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 5
some-alt