服务器 发布日期:2024/12/28 浏览次数:1
docker pull season/fastdfs:1.2
docker run -ti -d --name trakcer -v /opt/fastdfs/tracker_data:/fastdfs/tracker/data --net=host season/fastdfs:1.2 tracker
注意替换{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
在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.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