麦克斯仇
Think different
160
文章
40586
阅读
首页
INDEX
文章
ARTICLE
关于
ABOUT
Docker命令4:docker volume(管理卷)
创建日期:
2020/01/09
修改日期:
2021/10/13
Docker
> 以下命令中,若有对 **VOLUME** 操作时,写 VOLUME NAME 当 VOLUME NAME 为自定义卷名时,需要写全 当 VOLUME NAME 为随机字符时,写前几个字符后按`tab`键自动补全 ### create 创建一个卷 ```bash docker volume create [OPTIONS] [VOLUME] Options: -d, --driver string Specify volume driver name (default "local") --label list Set metadata for a volume -o, --opt map Set driver specific options (default map[]) ``` ```bash # 创建一个卷名为demo docker volume create demo ``` ### ls 列出卷 ```bash docker volume ls [OPTIONS] Options: -f, --filter filter Provide filter values (e.g. 'dangling=true') --format string Pretty-print volumes using a Go template -q, --quiet Only display volume names ``` ```bash # 列出卷 docker volume ls ``` 列 | 说明 ---|--- DRIVER | 驱动 VOLUME NAME | 名称 ### inspect 显示一个或多个卷上的详细信息 ```bash docker volume inspect [OPTIONS] VOLUME [VOLUME...] Options: -f, --format string Format the output using the given Go template ``` ```bash # 显示一个卷的详细信息 docker volume inspect 88e1375b3613118cb5d653e400438948ca5836e605503a776af44baaf1869b4b ``` > inspect详细内容后期整理 ### rm 删除一个或多个卷(不能删除容器正在使用的卷) ```bash docker volume rm [OPTIONS] VOLUME [VOLUME...] Options: -f, --force Force the removal of one or more volumes # 强制删除一个或多个卷 ``` ```bash # 删除一个卷(即使使用 -f 参数,也无法删除正在使用的卷) docker volume rm 5cc53a11caf6cbb26781e11acf45917117c4cb03ff7b54d981b58d6a29780419 ``` ### prune 删除所有未使用的本地卷 ```bash docker volume prune [OPTIONS] Options: --filter filter Provide filter values (e.g. 'label=<label>') -f, --force Do not prompt for confirmation # 不提示确认 ``` ```bash # 删除所有未使用的本地卷(-f 不提示确认) docker volume prune -f ```
12
全部评论