Quickly Install and Configure FastDFS with Docker on macOS
This step‑by‑step guide shows how to pull a FastDFS Docker image, create tracker and storage containers, adjust their configurations, and verify file upload, providing a fast way to set up the distributed file system on a Mac host.
Prerequisites
Docker must be installed and running on the host machine.
Search and pull a FastDFS image
List available FastDFS images and pull the desired one (e.g., delron/fastdfs).
docker search fastdfs
docker pull delron/fastdfsStart the tracker container
Run a tracker container that listens on port 22122. Use host networking on Linux; on macOS or Windows map the port explicitly.
# Linux (host network)
docker run -d --network=host --name tracker \
-v /path/to/tracker:/var/fdfs delron/fastdfs tracker
# macOS / Windows (port mapping)
docker run -d --name tracker -p 22122:22122 \
-v /path/to/tracker:/var/fdfs delron/fastdfs trackerStart the storage container
Run a storage container that connects to the tracker. Replace <TRACKER_IP> with the actual IP address of the tracker (use the host's LAN IP when both containers run on the same machine).
docker run -d --name storage \
-p 8888:8888 -p 23000:23000 \
-e TRACKER_SERVER=<TRACKER_IP>:22122 \
-e GROUP_NAME=group1 \
-v /path/to/storage:/var/fdfs \
delron/fastdfs storagePort 8888 is used by the embedded Nginx for HTTP access, and 23000 is the storage service port.
Verify container status
docker ps
# Expected output includes both tracker and storage containers with ports 22122, 8888 and 23000 exposed.Adjust configuration inside the storage container
Enter the storage container (replace <CONTAINER_ID> with the actual ID shown by docker ps). docker exec -it <CONTAINER_ID> bash Update the HTTP port in /etc/fdfs/storage.conf if a different port is required:
# /etc/fdfs/storage.conf
http.server_port=8888The Nginx configuration resides at /usr/local/nginx/conf/nginx.conf. Ensure the listen directive matches the HTTP port defined above.
# /usr/local/nginx/conf/nginx.conf (excerpt)
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
}Test file upload
Place a test file (e.g., weixin.jpg) in the host directory mounted to /var/fdfs. Inside the storage container, run the FastDFS client to upload the file.
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf weixin.jpgThe command returns a storage path such as group1/M00/00/00/…jpg. Access the file via HTTP:
http://<HOST_IP>:8888/group1/M00/00/00/…jpgResult illustration
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Senior Brother's Insights
A public account focused on workplace, career growth, team management, and self-improvement. The author is the writer of books including 'SpringBoot Technology Insider' and 'Drools 8 Rule Engine: Core Technology and Practice'.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
