docker_practice/data_management/volume.md

98 lines
2.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#
`数据卷` 使 UnionFS
* `数据卷`
* `数据卷`
* `数据卷`
* `数据卷` 使
>`数据卷` 使 Linux mount
##
```bash
$ docker volume create my-vol
```
`数据卷`
```bash
$ docker volume ls
DRIVER VOLUME NAME
local my-vol
```
使 `数据卷`
```bash
$ docker volume inspect my-vol
[
{
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/my-vol/_data",
"Name": "my-vol",
"Options": {},
"Scope": "local"
}
]
```
##
`docker run` 使 `--mount` `数据卷` `docker run` `数据卷`
`web` `数据卷` `/usr/share/nginx/html`
```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
```
##
使 `web`
```bash
$ docker inspect web
```
`数据卷` "Mounts" Key
```json
"Mounts": [
{
"Type": "volume",
"Name": "my-vol",
"Source": "/var/lib/docker/volumes/my-vol/_data",
"Destination": "/usr/share/nginx/html",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
```
##
```bash
$ docker volume rm my-vol
```
`数据卷` Docker `数据卷` `数据卷`使 `docker rm -v`
使
```bash
$ docker volume prune
```