参考文档
docker volume create 详解:
https://docs.docker.com/engine/reference/commandline/volume_create/#description
Give a service access to volumes or bind mounts
https://docs.docker.com/engine/swarm/services/#give-a-service-access-to-volumes-or-bind-mounts
$docker plugin install --grant-all-permissions --alias vsphere store/vmware/docker-volume-vsphere
0.12: Pulling from store/vmware/docker-volume-vsphere
27de4a000433: Download complete
Digest: sha256:696017e620fe8d29c883f36b5676135eaa2c2b3c3810f82931efb8027369a186
Status: Downloaded newer image for store/vmware/docker-volume-vsphere:0.12
Installed plugin store/vmware/docker-volume-vsphere:0.12
# docker plugin ls
ID NAME DESCRIPTION ENABLED
2f833dcd59bc vsphere:latest VMWare vSphere Docker Volume plugin true
# esxcli software vib install -v /tmp/vmware-esx-vmdkops-0.12.ccfc38f.vib --no-sig-check
Installation Result
Message: Operation finished successfully.
Reboot Required: false
VIBs Installed: VMWare_bootbank_esx-vmdkops-service_0.12.ccfc38f-0.0.1
VIBs Removed:
VIBs Skipped:
# docker volume create --driver=vsphere --name=MyVolume1
MyVolume1
# docker volume ls
DRIVER VOLUME NAME
vsphere:latest MyVolume1@TestDatastore
# docker volume inspect MyVolume1
[
{
"Driver": "vsphere:latest",
"Labels": {},
"Mountpoint": "/mnt/vmdk/MyVolume1",
"Name": "MyVolume1",
"Options": {},
"Scope": "global",
"Status": {
"access": "read-write",
"attach-as": "independent_persistent",
"capacity": {
"allocated": "13MB",
"size": "100MB"
},
"clone-from": "None",
"created": "Fri Mar 24 07:46:36 2017",
"created by VM": "ubuntu1",
"datastore": "TestDatastore",
"diskformat": "thin",
"fstype": "ext4",
"status": "detached"
}
}
]
$docker volume create --driver=vsphere --name=defaultDsVolume -o size=10gb
defaultDsVolume
官方参考文档:http://vmware.github.io/docker-volume-vsphere/documentation/admin-cli.html
数据卷允许创建在任何地方,多主机之间能够互相访问。
[root@localhost:~]/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup create --name=vmgroup1 --default-datastore=_VM_DS
vmgroup 'vmgroup1' is created. Do not forget to run 'vmgroup vm add' to add vm to vmgroup.
[root@localhost:~]/usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid Name Description Default_datastore VM_list
------------------------------------ -------- ------------------------- ----------------- -------
11111111-1111-1111-1111-111111111111 _DEFAULT This is a default vmgroup _VM_DS
c821fcce-7f84-4e60-9773-1a94765f80de vmgroup1 _VM_DS
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=vmgroup1
Datastore Allow_create Max_volume_size Total_size
--------- ------------ --------------- ----------
_VM_DS True Unset Unset
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid Name Description Default_datastore VM_list
------------------------------------ -------- ------------------------- ----------------- -------
11111111-1111-1111-1111-111111111111 _DEFAULT This is a default vmgroup _VM_DS
c821fcce-7f84-4e60-9773-1a94765f80de vmgroup1 _VM_DS
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup create --name=vmgroup2 --default-datastore=_ALL_DS
Cannot use _ALL_DS as default datastore. Please use specific datastore name or _VM_DS special datastore
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=vmgroup1
Datastore Allow_create Max_volume_size Total_size
--------- ------------ --------------- ----------
_VM_DS True Unset Unset
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=vmgroup1 --description=New --new-name=new-vmgroup1 --default-datastore=_ALL_DS
Datastore datastore2 does not exist
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=vmgroup1 --description=New --new-name=new-vmgroup1 --default-datastore=_VM_DS
vmgroup modify succeeded
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid Name Description Default_datastore VM_list
------------------------------------ ------------ ------------------------- ----------------- -------
11111111-1111-1111-1111-111111111111 _DEFAULT This is a default vmgroup _VM_DS
c821fcce-7f84-4e60-9773-1a94765f80de new-vmgroup1 New _VM_DS
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access ls --name=new-vmgroup1
Datastore Allow_create Max_volume_size Total_size
--------- ------------ --------------- ----------
_VM_DS True Unset Unset
删除vmgrop1,并删除下面所有的卷
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup rm --name=vmgroup1 --remove-volumes
11111111-1111-1111-1111-111111111111 是默认卷,不允许被删除
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup ls
Uuid Name Description Default_datastore VM_list
------------------------------------ ------------ ------------------------- ----------------- -------
11111111-1111-1111-1111-111111111111 _DEFAULT This is a default vmgroup _VM_DS
c821fcce-7f84-4e60-9773-1a94765f80de new-vmgroup1 New _VM_DS
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup access -h
usage: vmdkops_admin.py vmgroup access [-h] {rm,add,set,ls} ...
optional arguments:
-h, --help show this help message and exit
Add or remove Datastore access and quotas for a vmgroup:
{rm,add,set,ls} action
rm Remove all access to a datastore for a vmgroup
add Add a datastore access for a vmgroup
set Modify datastore access for a vmgroup
ls List all access info for a vmgroup
[root@localhost:~] /usr/lib/vmware/vmdkops/bin/vmdkops_admin.py vmgroup update --name=new-vmgroup1 --description= --new-name=vmgroup1 --default-datastore=_VM_DS
vmgroup modify succeeded