拉取镜像
docker pull season/fastdfs:1.2
启动Tracker
docker run -ti -d --name trakcer -v /opt/fastdfs/tracker_data:/fastdfs/tracker/data --net=host season/fastdfs:1.2 tracker
启动Storage
留神替换{ipaddress}
docker run -ti -d --name storage -v /opt/fastdfs/storage_data:/fastdfs/storage/data -v /opt/fastdfs/store_path:/fastdfs/store_path --net=host -e TRACKER_SERVER:{ipaddress}:22122 season/fastdfs:1.2 storage
批改配置文件
vim的目录为cp后的目录,如我的目录为/usr/local/fastdfs/conf
将配置文件中上面的参数替换为本人相应的ip即可
docker cp storage:/fdfs_conf/. /usr/local/fastdfs/conf
vim tracker.conf
bind_addr=${ipaddress}
vim storage.conf
tracker_server=${ipaddress}:22122
vim client.conf
tracker_server=${ipaddress}:22122
//将批改完的配置文件cp回镜像中
docker cp /usr/local/fastdfs/conf/. storage:/fdfs_conf
//重启storage服务
docker restart storage
配置Nginx
在storage服务中将nginx.conf和mod_fastdfs.conf挂载进去
//nginx.conf配置文件中增加
location /group1/M00 {
#root /fastdfs/store_path/data;
ngx_fastdfs_module;
}
//在server外面配置跨域
配置跨域 在server外面
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
//mod_fastdfs.conf中增加
url_have_group_name=true
启动Nginx
留神:启动nginx时须要将上一步挂载进去的nginx.conf和mod_fastdfs.conf映射门路,所以须要依据本人的门路来写,同时记得替换{ipaddress}参数
docker run -id --name fastdfs_nginx --restart=always -v /opt/fastdfs/store_path:/fastdfs/store_path -v /usr/local/fastdfs/nginx_conf/nginx.conf:/etc/nginx/conf/nginx.conf -v /usr/local/fastdfs/nginx_conf/mod_fastdfs.conf:/etc/fdfs/mod_fastdfs.conf -p 8888:80 -e GROUP_NAME=group1 -e TRACKER_SERVER={ipaddress}:22122 -e STORAGE_SERVER_PORT=23000 season/fastdfs:1.2 nginx
配置防火墙
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
firewall-cmd --reload
发表回复