docker_practice/data_management/volume.md

98 lines
2.4 KiB
Go
Raw Normal View History

##
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
`数据卷` 使 UFS
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
* `数据卷` 使
2017-12-20 23:46:55 +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
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-24 12:30:18 +08:00
`docker run` 使 `--mount` `数据卷` `docker run` `数据卷`
2017-11-23 00:19:30 +08:00
2017-11-24 12:30:18 +08:00
`web` `数据卷` `/webapp`
2017-11-23 00:19:30 +08:00
```bash
$ docker run -d -P \
--name web \
2017-11-24 12:30:18 +08:00
# -v my-vol:/wepapp \
2017-11-23 00:19:30 +08:00
--mount source=my-vol,target=/webapp \
training/webapp \
python app.py
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": "/app",
"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
```