使用docker|使用docker compose安装FastDfs文件服务器的实例详解

docker-compose.yml

version: '2'services:fastdfs-tracker:hostname: fastdfs-trackercontainer_name: fastdfs-trackerimage: season/fastdfs:1.2network_mode: "host"command: trackervolumes:- ./tracker_data:/fastdfs/tracker/datafastdfs-storage:hostname: fastdfs-storagecontainer_name: fastdfs-storageimage: season/fastdfs:1.2network_mode: "host"volumes:- ./storage_data:/fastdfs/storage/data- ./store_path:/fastdfs/store_pathenvironment:- TRACKER_SERVER=xxx.xxx.xxx.xxx:22122command: storagedepends_on:- fastdfs-trackerfastdfs-nginx:hostname: fastdfs-nginxcontainer_name: fastdfs-nginximage: season/fastdfs:1.2network_mode: "host"volumes:- ./nginx.conf:/etc/nginx/conf/nginx.conf- ./store_path:/fastdfs/store_pathenvironment:- TRACKER_SERVER=xxx.xxx.xxx.xxx:22122command: nginx

需要注意:
network_mode 必须是host, 原因是当上传文件时,tracker会把storage的IP和端口发给client,如果是bridge模式,则发送的是内网IP,client无法访问到。
image采用season/fastdfs:1.2 不要用lastest, 因为lastest不包含nginx服务,其他fasdfs镜像均没有season的精简。
nginx.conf(用于提供http的方式下载文件)
listen 7003是ngingx服务访问端口,可自行切换
#usernobody; worker_processes1; #error_loglogs/error.log; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; events {worker_connections1024; } http {includemime.types; default_typeapplication/octet-stream; #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '#'$status $body_bytes_sent "$http_referer" '#'"$http_user_agent" "$http_x_forwarded_for"'; #access_loglogs/access.logmain; sendfileon; #tcp_nopushon; #keepalive_timeout0; keepalive_timeout65; #gzipon; server {listen7003; server_namelocalhost; #charset koi8-r; #access_loglogs/host.access.logmain; location /group1/M00 {root /fastdfs/storage/data; ngx_fastdfs_module; } #error_page404/404.html; # redirect server error pages to the static page /50x.html#error_page500 502 503 504/50x.html; location = /50x.html {roothtml; } }}

【使用docker|使用docker compose安装FastDfs文件服务器的实例详解】到此这篇关于使用docker-compose安装FastDfs文件服务器的文章就介绍到这了,更多相关docker-compose安装FastDfs内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

    推荐阅读