-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Persistent data volumes #111
Comments
would it be possible to have a some sort of |
actually, there are two options here:
|
The key principle to keep in mind is that we want to minimize how much the On Tue, Mar 26, 2013 at 7:40 AM, Mikhail Sobolev
|
|
(Just for the record) I realized one thing: the bound directory should somehow excluded from what is being tracked as "changes". I am not sure if a straightforward implementation would work right away. |
That will actually work out of the box—because docker tracks changes by checking the AUFS layer, and a bind mount wouldn't show up in the layer. |
+1 want |
👍 I want to see if I can get Ceph running in docker so that I can get docker running on Ceph. |
Updated the title for clarity. |
So, here's the current plan. 1. Creating data volumesAt container creation, parts of a container's filesystem can be mounted as separate data volumes. Volumes are defined with the -v flag. For example: $ docker run -v /var/lib/postgres -v /var/log postgres /usr/bin/postgres In this example, a new container is created from the 'postgres' image. At the same time, docker creates 2 new data volumes: one will be mapped to the container at /var/lib/postgres, the other at /var/log. 2 important notes:
2. Sharing data volumesInstead of creating its own volumes, a container can share another container's volumes. For example: $ docker run --volumes-from $OTHER_CONTAINER_ID postgres /usr/local/bin/postgres-backup In this example, a new container is created from the 'postgres' example. At the same time, docker will re-use the 2 data volumes created in the previous example. One volume will be mounted on the /var/lib/postgres of both containers, and the other will be mounted on the /var/log of both containers. 3. Under the hoodDocker stores volumes in /var/lib/docker/volumes. Each volume receives a globally unique ID at creation, and is stored at /var/lib/docker/volumes/ID. At creation, volumes are attached to a single container - the source of truth for this mapping will be the container's configuration. Mounting a volume consists of calling "mount --bind" from the volume's directory to the appropriate sub-directory of the container mountpoint. This may be done by Docker itself, or farmed out to lxc (which supports mount-binding) if possible. 4. Backups, transfers and other volume operationsVolumes sometimes need to be backed up, transfered between hosts, synchronized, etc. These operations typically are application-specific or site-specific, eg. rsync vs. S3 upload vs. replication vs... Rather than attempting to implement all these scenarios directly, Docker will allow for custom implementations using an extension mechanism. 5. Custom volume handlersDocker allows for arbitrary code to be executed against a container's volumes, to implement any custom action: backup, transfer, synchronization across hosts, etc. Here's an example: $ DB=$(docker run -d -v /var/lib/postgres -v /var/log postgres /usr/bin/postgres)
$ BACKUP_JOB=$(docker run -d --volumes-from $DB shykes/backuper /usr/local/bin/backup-postgres --s3creds=$S3CREDS)
$ docker wait $BACKUP_JOB Congratulations, you just implemented a custom volume handler, using Docker's built-in ability to 1) execute arbitrary code and 2) share volumes between containers. |
One aspect of the spec which is not yet determined: specifying read-only mounts. Any preference on the best way to extend the syntax? |
Can you specify --volumes-from more than once? |
@glasser I didn't consider it. One obvious problem is that 2 containers might each have a volume mounted on the same path - in which case the 2 volumes would conflict. I'm guessing you have a specific use case in mind? :) |
Sure, but that should be something that can be statically checked by docker while building the container, right? And yes :) |
Another use case for exposing the host file system is for communication via Unix Domain Sockets and mqueues, which use files as the connection point. Or maybe also exposing serial ports in /dev? The original proposal at the top of this thread would allow this, however, I don't think the "data volumes" spec covers it since it only deals with container-to-container bridging and extraction. This is concept definitely opposed to @shykes comment regarding repeatability on different hosts. Similarly, what I tried to do here with pinning CPUs (#439) is host-specific, albeit repeatable only if different hosts supports all the same key/values. But people who do this would be using some way of configuring/maintaining it all (like picking service endpoints filepaths/host:port or making sure all processes aren't pinned to the same CPU). |
I had an interesting discussion with @mpetazzoni yesterday about a rather Specifically, the concern was to operate the local MTA in a separate The challenge here is "partial volume sharing", i.e. the "shell" containers On Wed, Apr 24, 2013 at 3:49 PM, Evan notifications@github.com wrote:
|
So, I now have enough datapoints (ie people yelling at me) to acknowledge the need for "choosing your own adventure" when it comes to custom runtime configuration: cpu pinning, external mountpoints, etc. So, to quote @brianm, we need "escape hatches" for the experts without ruining the experience for everyone. To get back to external mountpoints for volumes, I am convinced and have a design in mind for the escape hatch, stay tuned. On Wed, Apr 24, 2013 at 3:49 PM, Evan notifications@github.com wrote:
|
.. and the design will solve your MTA example, jerome, as well as all those listed in this issue. On Wed, Apr 24, 2013 at 4:16 PM, Jérôme Petazzoni
|
Closed by #376 |
does the pull request #376 solve the use cases mentioned here? If so, is there any documentation about how to use it? |
…4968b7 $ git log --oneline dabebe21bf79..9ff6c6923cff 9ff6c69 Add FlagSet.FlagUsagesWrapped(cols) which wraps to the given column (moby#105) a9a634f Add BoolSlice and UintSlice flag types. (moby#111) a232f6d Merge pull request moby#102 from bogem/redundant 5126803 Merge pull request moby#110 from hardikbagdi/master 230dccf add badges to README.md c431975 Merge pull request moby#107 from xilabao/add-user-supplied-func-when-parse 271ea0e Make command line parsing available outside pflag 25f8b5b Merge pull request moby#109 from SinghamXiao/master 1fcda0c too many arguments 5ccb023 Remove Go 1.5 from Travis 86d3545 Clean up code I am interested in 9ff6c69 for a followup. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
A lot of applications store nontrivial amounts of data on disk and need it to be persisted outside the scope of the aufs filesystem.
Proposal:
Bonus points if you can use variable substitution in the bind path names eg.
Presumably this feature would manifest itself in config.json somewhat like this:
The text was updated successfully, but these errors were encountered: