1. Docker部署FastDFS

1. 查看fastdfs的镜像

1
docker search fastdfs

2. 拉取镜像

该版本包含Nginx

1
docker pull delron/fastdfs

3. 启动tracker服务

1
docker run -d --network=host --name tracker -v /home/docker/fastdfs/tracker:/var/fdfs delron/fastdfs tracker

4. 启动storage服务

1
docker run -d --network=host --name storage -e TRACKER_SERVER=106.15.72.229:22122 -v /home/docker/fastdfs/storage:/var/fdfs -e GROUP_NAME=group1 delron/fastdfs storage

5. 查看启动状态

6. 修改Nginx端口

(nginx默认端口为8888,如无需更改可跳过)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#1.进入storage容器
docker exec -it c29105366570 bash

#2.修改storage内部http.server_port在最后一行
vi /etc/fdfs/storage.conf
# the port of the web server on this storage server
http.server_port=8888

#3.修改Nginx端口与上面保持一致
vi /usr/local/nginx/conf/nginx.conf
server { listen 8888; .....};
#4.重启容器
docker restart c29105366570

7. 测试是否配置成功

1
2
3
4
5
6
7
8
9
#1.拷贝一张图片test.jpg到目录/home/docker/fastdfs/storage
#2.进入storage容器
docker exec -it c29105366570 bash
#进入fdfs目录
cd /var/fdfs
#运行命令
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.jpg
#运行成功后会返回地址
group1/M00/00/00/rBEavF5p1-mAUMqUAAAxJTqVeZc248.jpg

8.在浏览器中访问

http://106.15.72.229:8888/group1/M00/00/00/rBEavGBlfGSAS0meAAA27-_dw_g003.png