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

What's the purpose of the VOLUMEs in the Dockerfile? #446

Open
western-hoolock opened this issue Sep 18, 2023 · 2 comments
Open

What's the purpose of the VOLUMEs in the Dockerfile? #446

western-hoolock opened this issue Sep 18, 2023 · 2 comments

Comments

@western-hoolock
Copy link

I'm using this image with a docker-compose file to set environment variables, works nicely. However the VOLUME in the Dockerfile of this image is causing 5 new volume to be created every single time I do a docker-compose up/down.
What's the purpose of declaring those VOLUMEs in the Dockerfile? I know I can declare named volumes in my docker-compose file but I'm not sure why the VOLUME is needed in the Dockerfile in the first place.

@codefox42
Copy link

I must admit, that the documentation does not provide much guidance regarding when to declare VOLUMEs and when not. Some even advice against using this feature.

I think wisely used, VOLUMEs are a good thing, as they clearly define where a specific application is writing data to that one might want to persist. On the other hand it is up to the user to hook up named volumes he/she is interested in. Nevertheless it is important to know how to get rid of the anonymous volumes that are automatically created if you don't explicitly specify a volume. It depends on how you are running the container:

docker compose down --volumes

docker container rm --volumes

(For single short-lived experimental containers I prefer using docker run --rm ... in the first place which also takes care of removing anonymous volumes.)

@leoleozhu
Copy link

Now I understand why the previously configured shares are still accessible. The smb.conf file is located in the /etc volume created by the Dockerfile. So whenever I modify the SHARE environment variable in the docker-compose.yml file, it is appended to the configuration file, and the previous one is not erased even if the container is recreated.

This is not a common practice in Docker. If the configuration is intended to be persistent, the documentation should recommend that users supply a volume for that directory.

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

No branches or pull requests

3 participants