1. Prepare the docker environment
Second, search fastdfs mirror
3. Pull the image
docker pull delron/fastdfs
The reason for choosing the delron/fastdfs mirror is that it includes nginx and does not need to install nginx forwarding by itself. You can also choose qbanxiaoli/fastdfs, which also includes nginx
Fourth, start the tracker service
docker run -d --network=host --name tracker -v /root/fastdfs/tracker:/var/fdfs delron/fastdfs tracker
5. Start the storage service
docker run -d --name storage --restart=always --net host -v /root/fastdfs/storage:/var/fdfs -e TRACKER_SERVER="IP:22122" delron/fastdfs storage
Note that if it is a cloud server, you need to change the IP to the external network ip
6. Points to note
1. If it is a cloud server, you need to open ports 22122, 23000, and 8888 in the security group entry direction of the cloud server background, and open the above three ports in the cloud server firewall configuration.
2. Test whether the build is successful
docker exec -it storage /bin/bash echo "Hello FastDFS">index.html fdfs_test /etc/fdfs/client.conf upload index.html
If the deployment is successful, the following screenshot should be returned after executing the above command
3. Access the resources just tested and uploaded
The default address is http://ip:8888/url, where ip is the external network ip, and url is the value of remote_filename spliced with the group_name value returned after uploading
As shown above, the access address is http://ip:8888/group1/M00/00/00/wKgARmCu6TCAKyFbAAAADpNIeWE63_big.html
7. Modify the access port
Enter the storage container (docker exec -it storage bash), find the configuration file storage.conf in the /etc/fdfs directory, modify http.server_port=8888 to the port you want,
Enter the conf under the nginx installation directory (/usr/local/nginx), modify the 8888 port in nginx.conf to the port you want, and it must correspond to the http.server_port in the previous step
Restart nginx
Restart storage
Note: After modifying the port, if it is a cloud server, you need to go to the cloud server background security group to release the modified port in the ingress direction and release the modified port in the cloud server firewall
The above are the details of some precautions for installing fastdfs images with docker. For more information about installing fastdfs with docker, please pay attention to other related articles!