happyfish100 / fastdfs

FastDFS is an open source high performance distributed file system (DFS). It's major functions include: file storing, file syncing and file accessing, and design for high capacity and load balance. Wechat/Weixin public account (Chinese Language): fastdfs
GNU General Public License v3.0
9.02k stars 1.99k forks source link

用docker安装后 storage的IP地址映射宿主地址问题 #336

Open kiritoowo opened 5 years ago

kiritoowo commented 5 years ago

storage的地址是docker虚拟网卡的地址 无法获取服务端连接资源:can't create connection to 172.17.0.1:23000

tangxiaonian commented 4 years ago

这个怎么解决的,,我也遇到了!!!

kiritoowo commented 4 years ago

使用了一个指令,让容器直接映射本机端口 --network=host

tangxiaonian commented 4 years ago

ok ,谢谢了

dezhenglu commented 4 years ago

请问有没有其他解决方案啊? 这样一来每次都要改conf的

kiritoowo commented 4 years ago

可以使用docker network create somenetwork 创建网络并进行统一设置,不过启动的时候也需要加入--net somenetwork指定自定义网络 ,可以参考官方文档进行自定义设置,官方文档地址:https://docs.docker.com/engine/reference/commandline/network_create/

wujushan commented 4 years ago

可以试下使用overlay网络模式或者双网卡的模式bridge+overlay。在storage_ids.conf里面使用服务名。

docker-compose.yml

version: '3'
services:
   webservice:
     networks:
       - frontend
   apiservice:
     networks:
     # 因为apiservice除了要与fdfs的tracker和storage通信,还要与webservice通信,所以使用了双网卡
       - frontend
       - backend
   fdfs-tracker0:
     networks:
       - backend
    fdfs-tracker1:
      networks:
       - backend
    fdfs-storage0:
      networks:
       - backend
    fdfs-storage1:
      networks:
       - backend
networks:
# frontend网络用于其他服务的互相通信
  frontend:
    driver: bridge
# backend网络用于fdfs的tracker storage和client互相通信
  backend:
    driver: overlay

storage_ids.conf

10001 group1 fdfs-storage0
10002 group1 fdfs-storage1

storage.conf

tracker_server=fdfs-tracker0:22122
tracker_server=fdfs-tracker1:22122