Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • I heavily disagree. You can still define volume mappings. "If you don't add VOLUME to your Dockerfile while creating the image, you will have to rely on the end developer to make sure they add that volume and if they don't then your POD will lose crucial state [...]". If there's crucial data that needs persisted, the developer / DevOps team should be made aware in the image docs and map it to persist in the correct place. The anonymous volume may end up persisting data in a short lived physical device , which can be terminated later, causing all kinds of issues. Commented Feb 1, 2024 at 19:05
  • You said it that it should be made aware in the docs. But good programming practices can not rely purely on documentation. The VOLUME forces the intent of the original author and it is definitely needed. It similar to when you design an image and you must provide an environment variable for example, it is not optional. By design the author of that image knows that this is needed and you won't get full functionality without it, hence forcing it. The Volume instruction kind of does the same thing. Forces the intent of the author. Commented Feb 1, 2024 at 20:15
  • Now problems and issues start when you do have a VOLUME and you didn't properly add that volume in your particular setup, but how can the removal of the original VOLUME instruction help in this case? It doesn't. Furthermore, inspecting a particular image and checking the volumes section of it, directly reflects the intent of the author in that "look here, these volumes must exist" it is self documenting in this respect in the metadata itself. Commented Feb 1, 2024 at 20:18
  • If a volume is needed, but wasn't added in the Dockerfile, the first time the container is recreated would allow the developer to know the issue, while an anonymous volume may make it seem like it's working even after the container is recreated, which makes reproducing errors more difficult, if the volume should be persisted in a different physical device. Commented Feb 2, 2024 at 11:55
  • I agree that the developer should not need to know everything the container does, docker is especially good to encapsulate behaviour in the way it separates the dependencies of the container from the dependencies of other containers and the machine, for example. But a volume is something that persists even after container recreation and is something that is changed outside the container, so I would strongly advise that anyone that uses an image should know at least the volumes and ports a container created from an image expects (basically, its interface with the outside). Commented Feb 2, 2024 at 11:59