一、背景
- 使用的是containerd,不是docker,但都一样;
- 在使用
-v
选项的时候,本来应该挂载上的目录没有挂载上; - 错误的示例如下:
#!/bin/bash #Program: # start client #History: #2023/12/02 junfenghe.cloud@qq.com version:0.0.1 msg:0.0.1 path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:~/bin export path nerdctl run -it -v /wisdomdata/target/lib:/home/cloudwave/data/edataserver/lib -v /wisdomdata/target:/home/cloudwave/data/edataserver/target -v /wisdomdata/conf:/home/cloudwave/data/edataserver/conf -p 9999:9999 --name wisdomdata-server registry.cloudwave.cn/wisdomdata-server:0.1.24 /bin/bash
二、解决办法:
经过多次搜索之后,发现是自己对 -v
用法的不熟练,上面错误示例里头,我将宿主机的目录写成了容器内目录,这肯定是不行的,正确的语法如下:
nerdctl run ... -v [主机目录]:[容器目录] [镜像名称]
七镜在这犯的错误就是将“主机目录” 和 “容器目录”给弄反了。
正确的用法如下:
#!/bin/bash #Program: # start client #History: #2023/12/02 junfenghe.cloud@qq.com version:0.0.1 msg:0.0.1 path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:~/bin export path # nerdctl run -it -v /wisdomdata/target/lib:/home/cloudwave/data/edataserver/lib -v /wisdomdata/target:/home/cloudwave/data/edataserver/target -v /wisdomdata/conf:/home/cloudwave/data/edataserver/conf -p 9999:9999 --name wisdomdata-server registry.cloudwave.cn/wisdomdata-server:0.1.24 /bin/bash nerdctl run -it -v /home/cloudwave/data/edataserver/lib:/wisdomdata/lib -v /home/cloudwave/d