Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VOLUME declaration can result in difficult to diagnose misbehavior #410

Closed
HoloRin opened this issue May 19, 2020 · 5 comments
Closed

VOLUME declaration can result in difficult to diagnose misbehavior #410

HoloRin opened this issue May 19, 2020 · 5 comments
Assignees
Labels
Request Request for image modification or feature

Comments

@HoloRin
Copy link
Contributor

HoloRin commented May 19, 2020

By declaring the VOLUME $RABBITMQ_DATA_DIR in the base Dockerfile, (i.e.

VOLUME $RABBITMQ_DATA_DIR
), it ensures that changes to that directory in subsequent Dockerfiles are ignored. This can cause very confusing behavior if, for instance, a user wants to add a specific erlang cookie in a new Dockerfile that inherits from this one. Additionally, if the behavior of rabbitmq-plugins were to change such that relies on modifying the data dir, the management Dockerfile would at least partially break.

@HoloRin
Copy link
Contributor Author

HoloRin commented May 19, 2020

https://docs.docker.com/engine/reference/builder/#volume

If any build steps change the data within the volume after it has been declared, those changes will be discarded.

I also tried redeclaring the VOLUME after making the desired changes, however the behavior remains unchanged:

FROM rabbitmq:3.8

RUN echo "test" > ${RABBITMQ_DATA_DIR}/test.txt && cat ${RABBITMQ_DATA_DIR}/test.txt

VOLUME $RABBITMQ_DATA_DIR
docker build . -t dvdt
docker run --rm -it dvdt /bin/cat /var/lib/rabbitmq/test.txt

which prints

/bin/cat: /var/lib/rabbitmq/test.txt: No such file or directory

So, I believe the only available solution is to drop the VOLUME declaration from the Dockerfile.

@wglambert wglambert added the Request Request for image modification or feature label May 19, 2020
@wglambert
Copy link

Other discussions on removing inherent volumes in images docker-library/mongo#306, redis/docker-library-redis#140, docker-library/postgres#404, docker-library/mysql#255

docker-library/cassandra#180 (comment)

While I agree it's unfortunate Docker doesn't have a feature to disable inherited volumes, I really hesitate to add extra explicit variants that then need to be maintained to support this.

@HoloRin
Copy link
Contributor Author

HoloRin commented Jun 10, 2020

I'd like to propose #416 as a solution with minimal maintenance overhead.

@edvinkuric
Copy link

Yeah, that is a known issue: moby/moby#3639

i always had to replace the volume-command manually in a fork of that image

@lukebakken lukebakken self-assigned this Feb 8, 2023
@lukebakken
Copy link
Collaborator

Closing since the behavior reported in this comment does not seem to be the case anymore.

Please see the following project for the Dockerfile I used, my environment, and a Makefile to build and run the image:

https://github.com/lukebakken/docker-library-rabbitmq-410

@lukebakken lukebakken closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

4 participants