如何使用文件系统在 docker 中创建卷?

how to create a volume in docker with filesystem?

Docker是否支持使用特定文件系统创建卷?我找不到任何 API 要求它,但我可以看到一些文件说它可以。

我正在尝试使用 curl 命令:

curl -H "Content-Type: application/json" -X POST -d'{
  "name":"visadfasfas","scope":"local","driver":local,"type":"tmpfs"
}' https://<HOST-IP>:2376/volumes/create

所以它创建了卷,但我看不到响应的卷类型。

Looks 文档列出了类型 here

+---------------+---------------------+
|  Technology   | Storage driver name |
+---------------+---------------------+
| OverlayFS     | overlay or overlay2 |
| AUFS          | aufs                |
| Btrfs         | btrfs               |
| Device Mapper | devicemapper        |
| VFS           | vfs                 |
| ZFS           | zfs                 |
+---------------+---------------------+

希望对您有所帮助。

是的,我们可以在 docker.but 中创建具有特定文件系统的卷,他们没有在任何文档中公开 json。

我在文档中看到以下提示并尝试创建 json。

DriverOpts - A mapping of driver options and values. These options are passed directly to the driver and are driver 

这是它的工作 json :

curl -H "Content-Type: application/json" -X POST -d'{
  "Name": "vish-test-btrfs",
"DriverOpts":{
"type":"<<<file-system-type>>>"
},
  "Scope": "local"
}' https://<<<HOST_IP>>>>:2376/volumes/create

<<<file-system-type>>> : can be btrfs, aufs etc ..

response看不到文件系统的类型,验证方式是

$ : cd <mount point of the volume>

eg :

$: cd /var/lib/docker/volumes/<<volume-Name>>/_data

come one directory back  

$ : cd ..

您可以在此处查看 .json 文件,我们可以在其中查看文件系统类型。

$: cat <filename.json>