Docker installing fastdfs


Pull 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 to replace {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 profile

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 your own corresponding IP address

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

vim tracker.conf

vim storage.conf

vim client.conf

#Return the modified configuration file CP to the image
docker cp /usr/local/fastdfs/conf/. storage:/fdfs_conf

#Restart the storage service
docker restart storage

Configure nginx

In the storage service, nginx Conf and Mod_ fastdfs. Conf mount out

#nginx. Add in conf configuration file
location /group1/M00 {
            #root   /fastdfs/store_path/data;

#Configure cross domain in the server. Configure cross domain in the server
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. Add in conf

Start nginx

Note: when starting nginx, you need to install the nginx installed in the previous step Conf and Mod_ fastdfs. Conf mapping path, so you need to write 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

Configure 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