You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anonymous volumes are created when an image has a VOLUME instruction. They will initialize by copying any of the existing content at the mount point (unlike a bind mount volume which typically replaces content at the mount point):
With docker run --rm ..., each container instance started will create a new anonymous volume. Without the --rm, these will accumulate pointlessly while the user may not be aware of this implicit waste on their system.
Docker Compose behaves differently, with additional logic to preserve the same anonymous volume across instances of the container for a given compose project.
The VOLUME instruction provides no value to an image. It only causes problems.
For detailed justification, please see below context for my previous write-up on this subject:
This issue is being raised across docker-library repos (with the only change the Dockerfile referenced snippet to change). It is similar to the past (stale?) docker-library issues for mongo, postgres, mysql, redis.
It is unclear why those older related issues on this topic have remained open for 6-8 years instead of resolving them. If a maintainer could clarify any pragmatic reason to keep VOLUME as a blocker, that would be appreciated. So far the only reason I recall is with Docker Compose, but that seems like a weak argument when persistence actually matters it should be explicit.
If the length (plus varying discussion chains) and age of those issues contribute to the lack of resolution, the issue I raise here hopefully condenses justification for removal into a consistent an easier to digest manner to drive this change forward.
As these are images maintained officially under the docker-library umbrella, it would help endorse VOLUME as an anti-pattern instead of encourage it's usage.
The text was updated successfully, but these errors were encountered:
polarathene
changed the title
Remove usage of the VOLUME directive
Remove usage of the VOLUME instruction
Feb 18, 2025
The
VOLUME
instruction should be removed from the image build.docker-library-redis/debian/Dockerfile
Lines 160 to 162 in 7109557
Anonymous volumes are created when an image has a
VOLUME
instruction. They will initialize by copying any of the existing content at the mount point (unlike a bind mount volume which typically replaces content at the mount point):docker run --rm ...
, each container instance started will create a new anonymous volume. Without the--rm
, these will accumulate pointlessly while the user may not be aware of this implicit waste on their system.The
VOLUME
instruction provides no value to an image. It only causes problems.For detailed justification, please see below context for my previous write-up on this subject:
Dockerfile
-VOLUME
directive is an anti-pattern kanidm/kanidm#2948Dockerfile
: RemoveVOLUME
instruction ory/hydra#3683VOLUME
instructions caddyserver/caddy-docker#118 (comment)VOLUME
published, but clearly documents aVOLUME
concern)Additional context (
docker-library
specific)This issue is being raised across
docker-library
repos (with the only change theDockerfile
referenced snippet to change). It is similar to the past (stale?)docker-library
issues for mongo, postgres, mysql, redis.It is unclear why those older related issues on this topic have remained open for 6-8 years instead of resolving them. If a maintainer could clarify any pragmatic reason to keep
VOLUME
as a blocker, that would be appreciated. So far the only reason I recall is with Docker Compose, but that seems like a weak argument when persistence actually matters it should be explicit.If the length (plus varying discussion chains) and age of those issues contribute to the lack of resolution, the issue I raise here hopefully condenses justification for removal into a consistent an easier to digest manner to drive this change forward.
As these are images maintained officially under the
docker-library
umbrella, it would help endorseVOLUME
as an anti-pattern instead of encourage it's usage.The text was updated successfully, but these errors were encountered: