Operations 8 min read

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.

Senior Brother's Insights
Senior Brother's Insights
Senior Brother's Insights
Quickly Install and Configure FastDFS with Docker on macOS

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/fastdfs

Start 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 tracker

Start 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 storage

Port 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=8888

The 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.jpg

The 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/…jpg

Result illustration

FastDFS upload result
FastDFS upload result
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Dockerfile uploadstoragemacOSFastDFSTracker
Senior Brother's Insights
Written by

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'.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.