docker_practice/data_management/volume.md

98 lines
2.5 KiB
Go
Raw Permalink Normal View History

#
2017-11-23 00:19:30 +08:00
`数据卷` 使 UnionFS
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
* `数据卷`
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
* `数据卷`
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
* `数据卷`
2017-11-24 12:30:18 +08:00
* `数据卷` 使
>`数据卷` 使 Linux mount
2014-09-16 13:31:53 +08:00
##
2014-09-16 13:31:53 +08:00
2017-11-13 18:54:38 +08:00
```bash
2017-11-23 00:19:30 +08:00
$ docker volume create my-vol
2014-09-05 15:56:33 +08:00
```
2017-11-24 12:30:18 +08:00
`数据卷`
2017-11-13 18:54:38 +08:00
```bash
2017-11-23 00:19:30 +08:00
$ docker volume ls
DRIVER VOLUME NAME
2017-11-23 00:19:30 +08:00
local my-vol
2014-09-05 15:56:33 +08:00
```
2014-09-16 13:31:53 +08:00
2017-11-24 12:30:18 +08:00
使 `数据卷`
2014-09-05 15:56:33 +08:00
2017-11-13 18:54:38 +08:00
```bash
2017-11-23 00:19:30 +08:00
$ docker volume inspect my-vol
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my-vol/_data",
"Name": "my-vol",
"Options": {},
"Scope": "local"
}
]
```
##
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
`docker run` 使 `--mount` `数据卷` `docker run` `数据卷`
2017-11-23 00:19:30 +08:00
`web` `数据卷` `/usr/share/nginx/html`
2017-11-23 00:19:30 +08:00
```bash
$ docker run -d -P \
--name web \
# -v my-vol:/usr/share/nginx/html \
--mount source=my-vol,target=/usr/share/nginx/html \
nginx:alpine
2014-09-05 15:56:33 +08:00
```
##
2017-11-23 00:19:30 +08:00
使 `web`
2017-11-13 18:54:38 +08:00
```bash
$ docker inspect web
```
2017-11-23 00:19:30 +08:00
`数据卷` "Mounts" Key
2017-11-13 18:54:38 +08:00
```json
2017-01-20 17:10:20 +08:00
"Mounts": [
2017-11-23 00:19:30 +08:00
{
"Type": "volume",
"Name": "my-vol",
"Source": "/var/lib/docker/volumes/my-vol/_data",
"Destination": "/usr/share/nginx/html",
2017-11-23 00:19:30 +08:00
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
```
##
2017-11-23 00:19:30 +08:00
2017-11-13 18:54:38 +08:00
```bash
2017-11-23 00:19:30 +08:00
$ docker volume rm my-vol
2014-09-05 15:56:33 +08:00
```
2014-09-16 13:31:53 +08:00
2017-11-24 12:30:18 +08:00
`数据卷` Docker `数据卷` `数据卷`使 `docker rm -v`
2017-11-23 00:19:30 +08:00
使
```bash
$ docker volume prune
```