docker-compose启动报错Error response from daemon: xxx is mounted on / but it is not a shared mount.

本文记录了一次Docker启动失败的问题及解决方案。作者在启动Docker容器时遇到错误提示,原因是配置文件路径指定不当。通过调整volume挂载路径中多余的斜杠,成功解决了启动问题。

今天docker启动时遇到无法启动的情况,苦苦搜索了半天(这里吐槽一下某度真的垃圾),最后通过谷歌找到一个日文链接,得到了解决办法,这里记录一下

host@DESKTOP-H1UNVPM:~/workspace/heating/compose$ docker-compose up -d
	[+] Running 6/7
	 ⠿ Network heating_dev_default          Created                                                                                                                                                             0.7s
	 ⠿ Container heating_dev_redis_1        Created                                                                                                                                                             0.1s
	 ⠿ Container heating_dev_loki_1         Created                                                                                                                                                             0.1s
	 ⠿ Container heating_dev_nginx_1        Created                                                                                                                                                             0.1s
	 ⠋ Container heating_dev_mqtt-broker_1  Creating                                                                                                                                                            0.1s
	 ⠿ Container heating_dev_prometheus_1   Created                                                                                                                                                             0.1s
	 ⠿ Container heating_dev_mysql_1        Created                                                                                                                                                             0.1s
	Error response from daemon: path /home/wjl/workspace/heating/compose/mosquitto/config is mounted on / but it is not a shared mount.

docker-compose.yml里的写法如下

volumes:
      - ./mosquitto/config:/mosquitto/config/:ro

问题出在config后面的/
解决办法,删掉最后的那个/

volumes:
      # - ./mosquitto/config:/mosquitto/config/:ro
      - ./mosquitto/config:/mosquitto/config:ro
[root@fanruan bin]# ./finekey INFO : 2025/07/23 15:34:42 Reading config file /opt/ops/finekey/conf/finekey.yaml INFO : 2025/07/23 15:34:42 use default ip:192.168.100.120 INFO : 2025/07/23 15:34:42 192.168.100.120 use local exec INFO : 2025/07/23 15:34:42 exec sudo success INFO : 2025/07/23 15:34:42 node selinux status check pass got [Disabled] INFO : 2025/07/23 15:34:42 node root path acls check pass INFO : 2025/07/23 15:34:42 begin check config valid! INFO : 2025/07/23 15:34:42 The deployment mode is online INFO : 2025/07/23 15:34:42 over check config valid! INFO : 2025/07/23 15:34:42 node 192.168.100.120 check ~/data/fanruan_71df1430 path auto mount or not INFO : 2025/07/23 15:34:42 node 192.168.100.120 found ~/data/fanruan_71df1430 path auto mounted INFO : 2025/07/23 15:34:42 begin check net and port~ INFO : 2025/07/23 15:34:42 begin start server and bind ports in all nodes~ INFO : 2025/07/23 15:34:43 192.168.100.120 time: 2025-07-23/15:34:43 +0800 INFO : 2025/07/23 15:34:43 start check net config bip and fip INFO : 2025/07/23 15:34:43 [MTUChecker] interface ens192 mtu 1500. INFO : 2025/07/23 15:34:44 192.168.100.120 begin install docker~ INFO : 2025/07/23 15:34:44 skip add docker group to user root INFO : 2025/07/23 15:34:44 docker exist, docker client version:Docker version 26.1.4, build 5650f9b INFO : 2025/07/23 15:34:44 no need to check docker bin path for docker version [26.1.4] INFO : 2025/07/23 15:34:44 node 192.168.100.120 no need to check docker bin path for docker version [26.1.4] INFO : 2025/07/23 15:34:44 chosen docker version:Docker version 26.1.4, build 5650f9b INFO : 2025/07/23 15:34:44 docker already start! INFO : 2025/07/23 15:34:44 docker install success ERROR: 2025/07/23 15:34:44 create network fanruan_exporter_net failed, cmd : docker network create fanruan_exporter_net --subnet=10.17.0.0/16 --gateway=10.17.0.1 --opt com.docker.network.bridge.name=br-fanruan , error: res:Error response from daemon: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-fanruan -j RETURN: iptables: No chain/target/match by that name. (exit status 1)) , err:exit status 1 ERROR: 2025/07/23 15:34:44 create exporter net failed, error: res:Error response from daemon: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-fanruan -j RETURN: iptables: No chain/target/match by that name. (exit status 1)) , err:exit status 1 ERROR: 2025/07/23 15:34:44 install docker and repo error! please check check error log info! INFO : 2025/07/23 15:34:44 begin rollback deployed components ERROR: 2025/07/23 15:34:44 deployment fail, please check error log info and fix it! bye~
07-24
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值