![]() The documentation for Docker 1.10.2 (API version 1.22) mentions under the "Create a container"[1] section that `HostConfig.Binds` can be given a "container path" which will automatically "create a new volume for the container." I interpreted this to mean it that the following two commands should have the same net result: # Create container with data volume via REST API curl --unix-socket /var/run/docker.sock -XPOST \ http://localhost/containers/create \ -H"Content-Type: application/json" \ -d'{ "Image": "<image-id>", ... "HostConfig": { "Binds": [ "/some/data/volume" ] } }' # Create container with data volume via CLI docker create -v /some/data/volume <image-id> <command> However, this turned out not the be the case, as the former would create a mount with no source and no corresponding volume: ... "Mounts": [ { "Source": "", "Destination": "/some/data/volume", "Driver": "local", "Mode": "", "RW": true, "Propagation": "rprivate" } ], ... "Config": { ... "Volumes": null, ... } ...whereas the latter would create a volume and mount it: ... "Mounts": [ { "Name": "9b38af46d6..." "Source": "/var/lib/docker/volumes/9b38af46d6.../_data", "Destination": "/some/data/volume", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ], ... "Config": { ... "Volumes": { "/some/data/volume": {} }, ... } However, if you instead specify the data volume via the `Volumes` key, then it works as expected, e.g. curl --unix-socket /var/run/docker.sock -XPOST \ http://localhost/containers/create \ -H"Content-Type: application/json" \ -d'{ "Image": "...", ... "Volumes": {"/some/data/volume": {}} }' ...will create a data volume and mount it. Thus the documentation is either incorrect, or this is a bug and the ability to create a data volume via `HostConfig.Binds` does not work as advertised for API version 1.22 (and likely others). I concluded that the documentation was incorrect. Since I've only verified this behavior for Docker 1.10.2, I updated the docs for API versions 1.22 and 1.23, but this may apply to other versions as well. [1] https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/#create-a-container Signed-off-by: Shane da Silva <shane@dasilva.io> |
||
---|---|---|
.. | ||
_static | ||
images | ||
docker-io_api.md | ||
docker_io_accounts_api.md | ||
docker_remote_api.md | ||
docker_remote_api_v1.14.md | ||
docker_remote_api_v1.15.md | ||
docker_remote_api_v1.16.md | ||
docker_remote_api_v1.17.md | ||
docker_remote_api_v1.18.md | ||
docker_remote_api_v1.19.md | ||
docker_remote_api_v1.20.md | ||
docker_remote_api_v1.21.md | ||
docker_remote_api_v1.22.md | ||
docker_remote_api_v1.23.md | ||
hub_registry_spec.md | ||
index.md | ||
README.md | ||
remote_api_client_libraries.md |
This directory holds the authoritative specifications of APIs defined and implemented by Docker. Currently this includes:
- The remote API by which a docker node can be queried over HTTP
- The registry API by which a docker node can download and upload images for storage and sharing
- The index search API by which a docker node can search the public index for images to download
- The docker.io OAuth and accounts API which 3rd party services can use to access account information