1,下载FastDFS镜像
docker pull morunchang/fastdfs
2,运行tracker
( -d 后台运行,别名tracker,使用网络模式是宿主机的IP)
docker run -d --name=tracker --net=host morunchang/fastdfs sh tracker.sh
3,运行storage
(使用的网络模式是–net=host, 166.171.221.12是宿主机的IP,OSS_1 是组名,即storage的组)
docker run -d --name storage --net=host -e TRACKER_IP=166.171.221.12:22122 -e GROUP_NAME=OSS_1 morunchang/fastdfs sh storage.sh
(注意:如果想要增加新的storage服务器,再次运行该命令,注意更换 新组名)
5,配置storage内置Nginx服务禁止缓存
(进入storage容器)
docker exec -it storage /bin/bash
6,进入配置文件
cd /etc/nginx/conf
7,打开配置文件
vi nginx.conf
8,开启禁止缓存
#所有以/M00开头的请求都会请求到 ngx_fastdfs_module
location ~ /M00 {
root /data/fast_data/data;
ngx_fastdfs_module;
#禁止缓存
add_header Cache-Control no-store;
}
9,退出容器
exit
10,重启storage容器
docker restart storage
11,配置自动重启
docker update --restart=always tracker
docker update --restart=always storage