文章目录
一、部署FastDFS
1、准备工作
bash
docker pull qinziteng/fastdfs:5.05
Pwd="/data/software/fastdfs"
mkdir ${Pwd}/{storage,tracker} -p
2、创建TEST容器,将fastdfs目录COPY到本地,方便后续维护管理!
bash
docker run -id --name fastdfs qinziteng/fastdfs:5.05
docker cp fastdfs:/home/fastdfs/conf /etc/fdfs
docker rm -f fastdfs
3、运行FastDFS容器
注意:TRACKER_SERVER
变量请替换成当前服务器IP:22122
!!!
bash
docker run -id --name fastdfs \
-v ${Pwd}/storage:/home/fastdfs/storage \
-v ${Pwd}/tracker:/home/fastdfs/tracker \
-v /etc/localtime:/etc/localtime \
-v /etc/fdfs:/home/fastdfs/conf \
--restart=always \
--net host \
-e TRACKER_SERVER="16.32.15.115:22122" \
qinziteng/fastdfs:5.05
二、部署Nginx(带FastDFS插件)
1、准备工作
bash
docker pull qinziteng/nginx-fastdfs:v1
mkdir /usr/local/nginx/conf.d -p
mkdir var/log/nginx -p
2、创建nginx配置文件
bash
cat > /usr/local/nginx/conf.d/nginx_fastdfs.conf << EOF
server {
listen 80;
server_name 127.0.0.1;
location ^~ /group1/M00/ {
alias /home/fastdfs/storage;
ngx_fastdfs_module;
charset 'utf-8';
}
location / {
root /usr/share/nginx/html;
index index.html;
}
}
EOF
3、运行Nginx容器
- Nginx容器基于FastDFS之上,所以一定要先部署FastDFS
TRACKER_SERVER
变量请和上面保持一致,就是Nginx要连接那个FastDFS
bash
docker run -itd --name nginx \
-v ${Pwd}/storage:/home/fastdfs/storage \
-v /etc/fdfs:/etc/fdfs \
-v /var/log/nginx:/var/log/nginx \
-v /etc/localtime:/etc/localtime \
-v /usr/local/nginx:/usr/local/nginx \
--restart=always \
-e TRACKER_SERVER="16.32.15.115:22122" \
-p 80:80 qinziteng/nginx-fastdfs:v1
三、FastDFS上传文件Nginx访问验证
1、进入FastDFS容器,上传文件
bash
docker exec -it fastdfs /bin/bash
echo "已经 $(date +%F,%T)了,还不休息????" > six.txt
fdfs_upload_file /home/fastdfs/conf/client.conf six.txt
group1/M00/00/00/ECAPc2UPGw6AfPG6AAAAN9ApjR8324.txt
把这个复制出来,加到访问nginx路径后面!
2、Nginx访问验证
浏览器访问:http://IP/group1/M00/00/00/ECAPc2UPGw6AfPG6AAAAN9ApjR8324.txt