![](/img/trans.png)
[英]Tomcat Docker Container: host webapp directory mounted as container webapp directory
[英]Docker - check within the container if a directory is mounted from the host or not
我需要检查我正在运行的容器中的目录是否从主机挂载。
示例:使用docker run .... -v /host-data:/data ....
命令。
如果没有挂载,我想警告用户,当容器终止时,这个目录上的数据将丢失......
我找到了一个粗略但简单的解决方案。
mount | grep '/data'
如果找到将导致0 (这意味着它已安装)。
我将它添加到我的入口点脚本中,它按预期工作。
欢迎提出改进意见!
我希望这有帮助。
mountVar=`mount | grep "$BLA"`
if [ -z "$mountVar" ]
then
echo "$BLA not mounted exit"
exit
else
echo "$BLA mounted "
fi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.