Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Managing Image Storage and Cleanup | Section
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

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 9

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

bookManaging Image Storage and Cleanup

Scorri per mostrare il 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

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 9
some-alt