Repository navigation
Description
Description of problem:
First, this problem might just go away when #14214 is completed.
However, for now in 1.8 when a volume driver (non-internal) is used, that volume driver is sent a VolumeDriver.create call for all of the volumes that are configured for an image. Including volumes that are built-in via Dockerfile. These "unnamed" or "automatic" hash-named volumes are potentially difficult to manage for a volume driver.
I would expect only the "named" volumes to be managed by the external volume driver, and all "unnamed" hash-named volumes to be handled internally (locally). Perhaps this is mistaken?
As an example: take the 'mongo' image. This image predefines a volume '/data/db'. Running a 'mongo' container this volume is automatically created.
However, if I specify a volume-driver to docker run, the volume driver is sent the pre-defined (hash-named) volume as well as any other volume that is specified with an explicit name.
Example:
docker-1.8.0-dev run -v test-volume:/new/path --volume-driver=blockbridge mongo
Volume driver received:
RECEIVED: VolumeDriver.Create: test-volume
RECEIVED: VolumeDriver.Create: bf99509b9a81fd090439770eda5594d5c82f6bb11293954cc944b39c5da9f152
The bf99509... volume is the one corresponding to the pre-defined '/data/db' volume.
If -v test-volume:/data/db is specified to docker run instead, now the paths overlap and only the 'test-volume' volume is created (as expected).
Questions:
- is this expected behavior?
- does Top-level volume management #14214 solve this?
- Is a volume driver supposed to 'deal with this', or require a user to know about all the pre-defined volumes for an image and specify each of them with an appropriate name.
Thanks!
docker version:
docker-1.8.0-dev version
Client:
Version: 1.8.0-dev
API version: 1.20
Go version: go1.4.2
Git commit: 533e816-dirty
Built: Mon Jul 27 20:16:08 UTC 2015
OS/Arch: linux/amd64
Experimental: true
Server:
Version: 1.8.0-dev
API version: 1.20
Go version: go1.4.2
Git commit: 533e816-dirty
Built: Mon Jul 27 20:16:08 UTC 2015
OS/Arch: linux/amd64
Experimental: true
docker info:
Containers: 55
Images: 597
Storage Driver: devicemapper
Pool Name: docker-253:1-70699164-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 9.103 GB
Data Space Total: 107.4 GB
Data Space Available: 112.6 MB
Metadata Space Used: 32.88 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 112.6 MB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.4.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 2
Total Memory: 2.782 GiB
Name: srust7-dev
ID: R7WO:GJ7Y:A7P5:PSRI:UGXM:5NAF:3NSR:N7FY:MI3K:YB4M:3IIY:HTFR
Username: blockbridge
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Experimental: true
uname -a:
Linux srust7-dev 3.10.0-229.4.2.el7.x86_64 #1 SMP Wed May 13 10:06:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Activity
cpuguy83 commentedon Jul 29, 2015
This is expected behavior, and has not changed from the experimental build.
The volumes still need to be created as an image doesn't actually have a volume, just a definition for one.
srust commentedon Jul 29, 2015
Hi Brian,
Thanks for the reply!
I can understand that behavior, since the
--volume-driverspecification is done atdocker runtime. So all volumes for that container use the same driver, regardless of named or not.Do you see this behavior changing in 1.9? It seems that #14242 moves the volume driver specification to each individual volume via
docker volume create --driver. What happens to the unnamed / pre-defined volumes from the image in that case? Are they treated as an internal (local) volume when they are created along with the container at run time? It doesn't seem that they could be associated with any external volume driver (which is fine, and preferred!). Unless of course volumes were created viadocker volume createthat matched the same path as the pre-defined image volumes.Thanks.
cpuguy83 commentedon Jul 29, 2015
Yes, the default driver is the
localdriver.srust commentedon Jul 29, 2015
Okay cool!
Would you consider changing the 1.8 behavior to match the expected 1.9 behavior? ie: named volumes specified to
docker runare passed to the external volume driver (if specified), but pre-defined image volumes are not, and use thelocaldriver (unless paths overlap).This would allow orchestration / users to specify the same basic parameters to docker run, and achieve the same expected result going forward, rather than changing behavior between releases. The #14242 functionality and behavior definitely seems like the way to go.
Thanks.
cpuguy83 commentedon Jul 29, 2015
Well the behavior isn't going to change, just that you will be able to pre-define volumes.
A named volume can be a local volume as well.
srust commentedon Jul 29, 2015
Yep absolutely. Just thinking about in 1.8 if any external volume driver is used for a container, then all pre-defined volumes in the image come along for the ride and are also sent to the external volume driver. But in 1.9, that wouldn't happen.
Anyway, not a huge deal overall. Thanks for the help and feedback.
cpuguy83 commentedon Jul 29, 2015
No, that's exactly what will happen.
"--volume-driver" applies to all volumes that don't already exist.
srust commentedon Jul 29, 2015
Oh, sorry! I figured the "--volume-driver" option was being removed from
docker runin 1.9, to be replaced by the more specificdocker volume create --driverconcept. That's where I was confused, my mistake. I'll close this up.