1, you can view all versions of fastDFS first
docker search fastdfs
I personally installed the delron/fastdfs version
2 , pull it down
docker pull delron/fastdfs
3 , check whether the pull is successful
docker images
Here we can see that the pull has been successful
4, use the docker image to build a tracker container (tracking the server, playing the role of scheduling)
docker run -dti --network=host --name tracker -v /var/fdfs/tracker:/var/fdfs delron/fastdfs tracker
Execute the following command to check whether the tracker is running
docker container ls
If you want to stop the tracker service, you can execute the following command
docker container stop tracker
After stopping, re-run the tracker, you can execute the following command
docker container start tracker
5, use the docker image to build a storage container (storage server, providing capacity and backup services)
docker run -dti --network=host --name storage -e TRACKER_SERVER=10.211.55.5:22122 -v /var/fdfs/storage:/var/fdfs delron/fastdfs storage
TRACKER_SERVER=Local IP: Default service port (22122)
6 , into the container
docker exec -it storage /bin/bash
Then we can enter the configuration file to see the default port
cd /etc/fdfs
cat storage.conf
Here we can see the default port number (it is recommended not to modify it)
7. If the above port number has been modified, you need to modify nginx in storage (no installation is required, because: installing fastdfs in docker comes with nginx, if you don’t use docker to install it with the installation package, you need to install nginx separately)
cd /usr/local/nginx/conf
vim nginx.conf
8 , If the above modification needs to restart the container, there is no need to restart if there is no modification
docker stop storage
docker start storage
9, open ports (because: some ports in the linux server firewall are not open and are disabled)
firewall-cmd --zone=public --permanent --add-port=8888/tcp
firewall-cmd --zone=public --permanent --add-port=22122/tcp
Then restart the firewall
systemctl restart firewalld
10, Start the container at boot (set the container to start with docker startup)
docker update --restart=always tracker
docker update --restart=always storage
11, we can test it, enter the container
docker exec -it storage /bin/bash
cd /var/fdfs
create a file
touch aaa.txt
edit file
vi aaa.txt
save file
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf aaa.txt
Here we upload successfully
Let's use the browser to visit again, as shown below:
Here we can access the file just stored on the browser
Here we have successfully installed and can be configured and used in java