moby/docs/reference/api
Shane da Silva 62fef18d69 Fix documentation for creating containers with data volumes
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>
2016-03-07 01:34:14 +00:00
..
_static retooling for hugo 2015-06-15 13:19:38 -07:00
images Implemet docker update command 2015-12-28 19:19:26 +08:00
docker-io_api.md Creating Engine specific menu 2016-01-26 15:58:53 -08:00
docker_io_accounts_api.md Creating Engine specific menu 2016-01-26 15:58:53 -08:00
docker_remote_api.md Add KernelMemory to "info" and show warning 2016-03-02 23:32:25 +01:00
docker_remote_api_v1.14.md Update docker_remote_api_v1.22.md and v1.23 to complete the docs 2016-02-22 20:49:10 +08:00
docker_remote_api_v1.15.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.16.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.17.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.18.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.19.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.20.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.21.md change container word spell in docs 2016-02-29 16:59:53 +08:00
docker_remote_api_v1.22.md Fix documentation for creating containers with data volumes 2016-03-07 01:34:14 +00:00
docker_remote_api_v1.23.md Fix documentation for creating containers with data volumes 2016-03-07 01:34:14 +00:00
hub_registry_spec.md Creating Engine specific menu 2016-01-26 15:58:53 -08:00
index.md Creating Engine specific menu 2016-01-26 15:58:53 -08:00
README.md Fixes found by docs validation tool 2015-11-23 11:19:38 +10:00
remote_api_client_libraries.md Update List of Client Library Projects 2016-02-08 16:16:42 -06:00

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