Skip to content

Conversation

@LeSpocky
Copy link
Member

change

Some containers (e.g. mariadb in default configuration) make use of volumes managed by Docker (see docker volume command). Old volumes not used by containers might pile up and eat storage. Remove those, too.

Compare output of docker system prune when called with or without --volumes option:

% docker system prune --all
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container 
  - all images without at least one container associated to them 
  - all build cache

Notice the additional line when calling with the option:

% docker system prune --all --volumes
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container 
  - all anonymous volumes not used by at least one container 
  - all images without at least one container associated to them 
  - all build cache

discussion

Not sure if this should be squashed into the existing command which is controlled with docker_image_prune or if we should introduce a separate variable for pruning volumes only? Opinions?

Some containers (e.g. mariadb in default configuration) make use of
volumes managed by Docker (see `docker volume` command).  Old volumes
not used by containers might pile up and eat storage.  Remove those,
too.

Compare output of `docker system prune` when called with or without
`--volumes` option:

    % docker system prune --all
    WARNING! This will remove:
      - all stopped containers
      - all networks not used by at least one container
      - all images without at least one container associated to them
      - all build cache

Notice the additional line when calling with the option:

    % docker system prune --all --volumes
    WARNING! This will remove:
      - all stopped containers
      - all networks not used by at least one container
      - all anonymous volumes not used by at least one container
      - all images without at least one container associated to them
      - all build cache
Copy link
Member

@penguineer penguineer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this should definitely be a distinct command/configuration, if not even a distinct (clean-up) role.

  1. Images can usually recovered by downloading them again. There is usually no data loss when an image is deleted even though it might be needed later on. In contrast, deleting a volume leads to data loss and doing so in a CRON job might delete data without the user's consent.
  2. Dangling images are part of normal operations, as software is frequently updated and old versions are no longer needed. Dangling volumes are part of development efforts and not "business as usual" for a docker environment.

@LeSpocky LeSpocky closed this May 14, 2025
@LeSpocky
Copy link
Member Author

Okay thanks for your thoughts. Makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants