-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Data-only containers obsolete with docker 1.9.0? #17798
Comments
Hi! Please read this important information about creating issues. If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead. If you suspect your issue is a bug, please edit your issue description to include the BUG REPORT INFORMATION shown below. If you fail to provide this information within 7 days, we cannot debug your issue and will close it. We will, however, reopen it if you later provide the information. This is an automated, informational response. Thank you. For more information about reporting issues, see https://github.com/docker/docker/blob/master/CONTRIBUTING.md#reporting-other-issues BUG REPORT INFORMATIONUse the commands below to provide key information from your environment:
Provide additional environment details (AWS, VirtualBox, physical, etc.): List the steps to reproduce the issue: Describe the results you received: Describe the results you expected: Provide additional info you think is important: ----------END REPORT --------- #ENEEDMOREINFO |
yes, named volumes should be able to replace data-only volumes in most (if not all) cases. @cpuguy83 any ideas of cases where data-only containers still make sense? We may have to further improve the docs around this |
Yep, no reason I can see to use data-only containers. |
Ok, so no more data-only containers :-) Thanks for verifying this! |
Do we have docs regarding data-only containers? If so we could leave this open until we fix those |
@runcom Yes, e.g. https://docs.docker.com/engine/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container. I suggest to refer to named volumes instead to prevent future confusion. |
Never really used data-only containers, but wouldn't there still be a need for them if you wanted a way to move data (not apps) between clouds? At that point the container becomes the portable-filesystem artifact. |
@duglin actually not, because the data-only container is only used to reference the volume through |
But, if I used the VOLUME Dockerfile command and then pre-populate that volume during the build process, won't that data be available whenever/wherever I deploy that image? |
Maybe a remaining use case is to have pre-seeded volumes from data only container (see #14242 (comment) for subtle differences between anonymous and named volumes). |
Another use case that keeps data only containers relevant is that you can use container affinity (--volumes-from=dependency) to make sure you container runs on the same node as the data container. At the moment there does not appear to be a filter for volume affinity. |
@runcom @trkoch @thaJeztah The section Creating and mounting a data volume container still says, "…it’s best to create a named Data Volume Container…". If this is no longer the case, can y'all make a ticket to get the docs updated? I'm certainly confused by this. ;P |
Already done: #20465 |
@cpuguy83 Great, thanks! |
Hi, I use that feature for nginx, php-fpm. I have nginx and php-fpm in two different containers. As nginx has a link to php-fpm I can not use volumes_from inside the php-fpm container as that would create a circular reference. So I found the solution to use a container that only has the php source code and both the nginx and the php-fpm container use the volumes_from feature. |
@carsten-ulrich-saitow-ag volumes-from is still supported (as is the possibility of using data-only containers), it's just that in many cases you don't need a data-only container per-se, because volumes can now be managed on their own (without the need for a container to be attached to it). Also, with the new networking, you can reach containers by name (or still provide a
Both containers share the "phpsource" volume (which is propagated with the content of the php-fpm containers the first time it's run). The nginx container can connect to the |
@carsten-ulrich-saitow-ag And the named volume
Oh, wait, @thaJeztah, when you say the volume is “propagated with the content of the php-fpm containers the first time it's run” do you mean it's not necessary to run |
@quinncomendant correct, you can either create the volume first ( If is important to do it in the right order, because the files inside the container are only copied to the volume by the first container that uses it (and the volume is still empty) |
If you need to apply permissions to a named volume, you're kind of SOL at the moment. When you create volumes with |
@damnhandy It is owned by whoever owns the data in the container at the path you mount it to (assuming it's the first time it's been mounted). |
What about a data only container when scaling in a swarm? For example scaling the same container to multiple host machines sharing the same volume? Is this the only use case or is scaling to the same host with the volume recommended? |
@robvelor the default ("local") volume driver is indeed local to a host (although swarm will create a volume with the same name on each host). You can, however, use a different driver/plugin; some plugins allow a volume to be shared or replicated on each host; you can find some plugins here; https://docs.docker.com/engine/extend/plugins/#finding-a-plugin |
@thaJeztah Yes, I forgot to add that I am using rexray to persist in the cloud (AWS-EBS) but the volume can only be mounted to one host machine, hence my question. Any thoughts on this? Maybe I need to use a different plugin to achieve multi-host volumes between containers. |
@robvelor hm, possibly yes; you could ask rex-ray what the options are with their plugin. Be aware, that it may also depend on the application that's writing to the volume; does the app support concurrent processes writing to the "same" volume. |
@thaJeztah Sorry for stupid question but I not fully realized. You said
But how to work with these volumes at host machine? For example to develop application and store it to the named volume. Sorry if the question is too stupid, but I actually don't quite understand 😐 |
Stand-alone volumes usually have root,root access until changed by a container with root access. If your container runs software as a normal user (e.g. jenkins, ...) there is no way to change the permissions of a volume mounted at runtime to normal user access for the container. A data-container can be used to run a single |
@derqnaque stand-alone volumes (As of 1.10) will work the same as anonymous volumes (e.g. |
Also in 1.11, you can supply |
@cpuguy83: The host volume might be something I don't have host access to (e.g. in a cloud setting where i am not the hoster). Mount options might work, if I know the filesystem that is in use on the host. And I think e.g. ext4 does not provide the uid, gid options. The data-container solution still seems a lot easier and more portable to me, since all I need to know is the The |
@derqnaque A named volume will act exactly like a |
Is there a way to create a named volume that stores the data of all So, is there something like a |
@nioncode no; you can't "nest" volumes, you'll have to assign a named volume for each folder, or (if you don't assign a named volume), docker creates "anonymous" / "unnamed" volumes for each volume that's declared in the Dockerfile |
@thaJeztah Is it also possible to automatically create data volumes with mount points? (Or do I just mix up auto-creation things?) Do you also know how to use data volume containers with docker-compose? |
@lukas-schulze if you mean bind-mounting a directory, that's a different thing: a bind-mounted directory ( If you want to easily access the volume data from your host, you code consider using a volume plugin for that https://docs.docker.com/engine/extend/plugins/#volume-plugins, for example, the "local persist" plugin allows you to specify an custom path where volumes are stored |
Define node_modules as named module so it will be automatically attached in one-off `docker-compose run` containers allowing `npm install` to have an effect without the need to rebuild containers. This requires compose file version 2 syntax: https://docs.docker.com/compose/compose-file/#/version-2 (which I think requires Docker Engine 1.10.0 or newer) For persisting with named modules, see: - brikis98/docker-osx-dev#168 (comment) - moby/moby#17798
What's the best alternative to something like this: docker create \
-v /var \
-v /bin \
-v /any/other/path \
--name data-xyz xyz /bin/true
docker run -d -p 80:80 --volumes-from data-xyz --name xyz xyz In other words, data only container with multiple paths? So far, best I could achieve is this: docker run -d -p 80:80 \
-v data-xyz-var:/var \
-v data-xyz-bin:/bin \
-v data-xyz-any-other-path:/any/other/path \
--name xyz xyz In other words for each directory I need separate volume? |
@arvenil as a replacement for "data-containers" generally looks good to me. Without knowing your exact use case however;
|
@thaJeztah hah, bad choice of examples from my side :) I shouldn't use /var /bin :) Sorry. I meant something more generic like /xyz /abc /qwe. I think what I'm looking for is a Group Volume, or a root
I would rather have a volume that keeps the paths, so I could have multiple paths in one volume
Maybe something like this: |
@thaJeztah Are there any plans to support grouping volumes or should we create volumes one by one for each declared VOLUME in a Dockerfile? For example, you start with a simple Dockerfile that just has a single VOLUME It would be nice to have a |
This is a question regarding best-practice, not sure this is the right place to ask but here it goes anyway:
So in docker 1.9.0 we can create named volumes. This means I could create a container with a named volume, then remove the container completely, and then re-create it again with the same named volume and the data would be retained. I think this was at least one (if not the only) purpose of data-only containers. So my question is if having data-only containers is still considered best-practice? Or can we now skip data-only containers completely and only use named volumes?
The text was updated successfully, but these errors were encountered: