Volumes

Create a volume

POST /api/v1/volumes/(string: volume_name)
Request JSON Object:
 
  • name (string) – The new volume’s name. If not specified, Docker generates a name. [required]
  • driver (string) – Name of the volume driver to use. Defaults to local for the name.
  • driver_opts (object) – A mapping of driver options and values. These options are passed directly to the driver and are driver specific.
  • labels (object) – Labels to set on the volume, specified as a map: {“key”:”value” [,”key2”:”value2”]} [currently not supported]

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{"name": "test_volume_1"}' \
    http://${QIP}:${QPORT}/container-station/api/v1/volumes

$ curl -sq -XPOST -b cookies.txt -d \
    '{"name": "test_volume_2",
      "labels": {"key":"value"},
      "driver_opts": {"device":"tmpfs","type":"tmpfs","o":"size=100m,uid=1000"}
    }' \
    http://${QIP}:${QPORT}/container-station/api/v1/volumes

Example response

{
    "CreatedAt": "2021-08-11T17:07:34+08:00",
    "Driver": "local",
    "Labels": null,
    "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/test_volume_1/_data",
    "Name": "test_volume_1",
    "Options": null,
    "Scope": "local"
}
{
    "CreatedAt": "2021-08-11T17:07:35+08:00",
    "Driver": "local",
    "Labels": {
        "key": "value"
    },
    "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/test_volume_2/_data",
    "Name": "test_volume_2",
    "Options": {
        "device": "tmpfs",
        "o": "size=100m,uid=1000",
        "type": "tmpfs"
    },
    "Scope": "local"
}

List volumes

GET /api/v1/volumes

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/volumes

Example response

[
    {
        "CreatedAt": "2021-08-11T16:55:14+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/3e31fb43e8e87e3cf1ba3c439962eec5dfb3c8ccac21f0a50510aa27aaa23ecd/_data",
        "Name": "3e31fb43e8e87e3cf1ba3c439962eec5dfb3c8ccac21f0a50510aa27aaa23ecd",
        "Options": null,
        "Scope": "local"
    },
    {
        "CreatedAt": "2021-08-11T16:55:13+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/7761c374c0ec3b260d25bfd9fabcddc297b5a05b3e18a4affd600286674a64c2/_data",
        "Name": "7761c374c0ec3b260d25bfd9fabcddc297b5a05b3e18a4affd600286674a64c2",
        "Options": null,
        "Scope": "local"
    },
    {
        "CreatedAt": "2021-08-11T16:50:57+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/bc1b89da45ffec81e0a1a07411758842886083ccbbc1a930bc02d32098eb01df/_data",
        "Name": "bc1b89da45ffec81e0a1a07411758842886083ccbbc1a930bc02d32098eb01df",
        "Options": null,
        "Scope": "local"
    },
    {
        "CreatedAt": "2021-08-11T17:07:34+08:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/test_volume_1/_data",
        "Name": "test_volume_1",
        "Options": null,
        "Scope": "local"
    },
    {
        "CreatedAt": "2021-08-11T17:07:35+08:00",
        "Driver": "local",
        "Labels": {
            "key": "value"
        },
        "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/test_volume_2/_data",
        "Name": "test_volume_2",
        "Options": {
            "device": "tmpfs",
            "o": "size=100m,uid=1000",
            "type": "tmpfs"
        },
        "Scope": "local"
    }
]

Inspect a volume

GET /api/v1/volumes/(string: volume_name)/inspect
Parameters:
  • volume_name – volume’s name

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/volumes/test_volume_2/inspect

Example response

{
    "CreatedAt": "2021-08-11T17:07:35+08:00",
    "Driver": "local",
    "Labels": {
        "key": "value"
    },
    "Mountpoint": "/share/CACHEDEV3_DATA/Container/container-station-data/lib/docker/volumes/test_volume_2/_data",
    "Name": "test_volume_2",
    "Options": {
        "device": "tmpfs",
        "o": "size=100m,uid=1000",
        "type": "tmpfs"
    },
    "Scope": "local"
}

Remove a volume

DELETE /api/v1/volumes/(string: volume_name)
Parameters:
  • volume_name – volume’s name

Example request

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/volumes/test_volume_2

Example response

{}

Remove all unused volumes

DELETE /api/v1/volumes/

Example request

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/volumes/

Example response

{
    "SpaceReclaimed": 0,
    "VolumesDeleted": [
        "test_volume_1",
        "test_volume_2",
        "test_volume_3"
    ]
}
{
    "SpaceReclaimed": 0,
    "VolumesDeleted": []
}