Docker Method Steps for Installing FastDFS

  • 2021-10-16 05:29:25
  • OfStack

Pull mirror image


docker pull season/fastdfs:1.2

Start Tracker


docker run -ti -d --name trakcer -v /opt/fastdfs/tracker_data:/fastdfs/tracker/data --net=host season/fastdfs:1.2 tracker

Start Storage

Note the replacement of {ipaddress}


docker run -ti -d --name storage -v /opt/fastdfs/storage_data:/fastdfs/storage/data -v /opt/fastdfs/store_path:/fastdfs/store_path --net=host -e TRACKER_SERVER:{ipaddress}:22122 season/fastdfs:1.2 storage

Modify the configuration file

The directory of vim is the directory after cp, for example, my directory is/usr/local/fastdfs/conf
Replace the following parameters in the configuration file with their own corresponding ip


docker cp storage:/fdfs_conf/. /usr/local/fastdfs/conf

vim tracker.conf
bind_addr=${ipaddress}

vim storage.conf
tracker_server=${ipaddress}:22122

vim client.conf
tracker_server=${ipaddress}:22122

# The configuration file that will be modified cp Back in the mirror image 
docker cp /usr/local/fastdfs/conf/. storage:/fdfs_conf

# Restart storage Services 
docker restart storage

Configuring Nginx

Mount nginx. conf and mod_fastdfs. conf in the storage service


#nginx.conf Configuration file to add 
location /group1/M00 {
      #root  /fastdfs/store_path/data;
      ngx_fastdfs_module;
}

# In server It configures cross-domain configuration cross-domain   In server Inside 
add_header 'Access-Control-Allow-Origin' '*';
  add_header 'Access-Control-Allow-Credentials' 'true';
  add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

#mod_fastdfs.conf Add to 
url_have_group_name=true

Start Nginx

Note: When starting nginx, the mapping paths of nginx.conf and mod_fastdfs. conf mounted in the previous step need to be written according to your own path, and remember to replace the {ipaddress} parameter


docker run -id --name fastdfs_nginx --restart=always -v /opt/fastdfs/store_path:/fastdfs/store_path -v /usr/local/fastdfs/nginx_conf/nginx.conf:/etc/nginx/conf/nginx.conf -v /usr/local/fastdfs/nginx_conf/mod_fastdfs.conf:/etc/fdfs/mod_fastdfs.conf -p 8888:80 -e GROUP_NAME=group1 -e TRACKER_SERVER={ipaddress}:22122 -e STORAGE_SERVER_PORT=23000 season/fastdfs:1.2 nginx

Configuring a firewall


firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
firewall-cmd --reload

Related articles: