当前位置:网站首页>匿名挂载&具名挂载
匿名挂载&具名挂载
2022-06-28 00:16:00 【懒癌晚期大脸萌】
# 匿名挂载
-v 容器内路径
[[email protected] volumes]# docker run -d -P --name nginx02 -v /ect/nginx nginx # -P 随机端口
1e7a6f078e1d149a28870b080e8889fa943c0a3be94cb98b34e4b68fbaca7706
[[email protected] volumes]# docker volume --help
Usage: docker volume COMMAND
Manage volumes
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused local volumes
rm Remove one or more volumes
Run 'docker volume COMMAND --help' for more information on a command.
# 查看所有的 volume 情况
[[email protected] volumes]# docker volume ls #以下全是匿名卷挂载,在-v 只写了容器内路径,没有写容器外路径
DRIVER VOLUME NAME
local 85ceb1c90bf20638336243eba9185d8f733c19785e70699e95511e5022167d41
local 378d3ad8f128323116b58484f5fd19492b4e41d1213f729ed89cfc9c7f3524bc
local 94004da9bc144582354a4fa694fc647b7d700512eb1d0b220f47de9a521da753
local 40506974fbded9e29a84f42f33b737e28dc13eb0a821f1ebd991aa349bfac1bc
local aaac05064af330ebf935a3c42bf51f49aa82f319714b9e865fed5f875ee885ef
local c2956de8052af73afc7e00ebdc74f9a2f17e8f794bf551ce09fd45598e58c94f
# 查看卷在哪个位置:Mountpoint
[[email protected] ~]# docker volume inspect 85ceb1c90bf20638336243eba9185d8f733c19785e70699e95511e5022167d41
[
{
"CreatedAt": "2022-05-06T13:29:50+08:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/85ceb1c90bf20638336243eba9185d8f733c19785e70699e95511e5022167d41/_data",
"Name": "85ceb1c90bf20638336243eba9185d8f733c19785e70699e95511e5022167d41",
"Options": null,
"Scope": "local"
}
]
# 具名挂载
-v 卷名:容器内路径
[root[email protected] ~]# docker run -d -P --name nginx03 -v juming-nginx:/etc/nginx nginx
f89ab2645fc6cea48003e98d080b37d5aa5d3485740ee1d34df128c4872edcef
[[email protected] ~]# docker volume ls
DRIVER VOLUME NAME
local 2eba47cade6c5b68f4f2179df0511e49113f4c507aad448b2bc25fbb99cc4ecf
local 5f5d46c0cfe40408f71515d12b6d2bab31cfbe478716f125bab34d43c65e0776
local 54c20bfffe906d311d4394dccb85c4f7f2d2cee4ed295ff9682856a7c2a7d07b
local 85ceb1c90bf20638336243eba9185d8f733c19785e70699e95511e5022167d41
local 378d3ad8f128323116b58484f5fd19492b4e41d1213f729ed89cfc9c7f3524bc
local 94004da9bc144582354a4fa694fc647b7d700512eb1d0b220f47de9a521da753
local 40506974fbded9e29a84f42f33b737e28dc13eb0a821f1ebd991aa349bfac1bc
local aaac05064af330ebf935a3c42bf51f49aa82f319714b9e865fed5f875ee885ef
local c2956de8052af73afc7e00ebdc74f9a2f17e8f794bf551ce09fd45598e58c94f
local ccd77d73028a70a3433a374aea57d9e2c96828cddefe1a808eda0354ba3b7a44
local juming-nginx
[[email protected] ~]# docker volume inspect juming-nginx
[
{
"CreatedAt": "2022-05-29T14:43:14+08:00",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/juming-nginx/_data",
"Name": "juming-nginx",
"Options": null,
"Scope": "local"
}
]
所有docker容器内的卷,没有指定目录(可用docker info 命令查看目录)的情况下默认都是在 /var/lib/docker/volumes/xxx/_data 目录下
我们通过具名挂载可以方便的找到卷,大多数情况使用具名挂载
-v /容器内路径 # 匿名挂载
-v 卷名:/容器内路径 # 具名挂载
-v /宿主机路径:/容器内路径 #指定路径挂载,这种方式不会产生匿名卷
拓展
# 通过 -v 容器内路径:ro rw 改变读写权限
ro readonly -- 只读
rw readwrite -- 可读可写
docker run -d -P --name nginx03 -v juming-nginx:/etc/nginx:ro nginx
# 只要看到 ro 就说明这个路径只能通过宿主机来操作,容器内无法扫操作,默认为rw
边栏推荐
- 机器学习笔记 - 时间序列作为特征
- TI AM3352/54/59 工业核心板硬件说明书
- Cesium Color 颜色(赋值)随机颜色
- Jenkins - accédez à la variable de paramètre personnalisée Jenkins, en traitant les espaces dans la valeur de la variable
- [embedded foundation] memory (cache, ram, ROM, flash)
- Jenkins - access the Jenkins user-defined parameter variable, and handle the variable value containing spaces
- 外盘期货哪里可以开户?哪个平台出入金比较安全?
- 9. Openfeign service interface call
- [Yocto RM] 2 - Yocto Project Terms
- The practice of dual process guard and keeping alive in IM instant messaging development
猜你喜欢
Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
[Niuke discussion area] Chapter 4: redis
Maimai hot post: Why are big factories keen on making wheels?
自监督学习与药物发现
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)
【永艺XY椅】试用体验
TI AM3352/54/59 工业核心板硬件说明书
树莓派实现温控风扇智能降温
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
frp实现内网穿透
随机推荐
What is a web crawler
解决ionic4 使用hammerjs手势 press 事件,页面无法滚动问题
Cesium 抗锯齿(线,边框等)
Capacitor
【sylixos】i2c设备驱动创建和使用
OS module and os Learning of path module
Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
General process after reference layer reboot
Numpy----np.meshgrid()
【嵌入式基础】串口通信
Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
PV operation primitive
Cesium anti aliasing (lines, borders, etc.)
网络爬虫是什么
Self supervised learning and drug discovery
[elt.zip] openharmony paper Club - memory compression for data intensive applications
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
面试官问:能否模拟实现JS的new操作符
Cesium Click to draw polygons (dynamically draw polygons)
geojson 格式說明(格式詳解)