docker 和 FastDFS上传和下载文件

Posted wjun0

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker 和 FastDFS上传和下载文件相关的知识,希望对你有一定的参考价值。

1,从仓库拉取镜像

sudo docker image pull delron/fastdfs

 也可以解压已经打包好的镜像文件

$ sudo docker load -i 文件路径/fastdfs_docker.tar

2,开启tracker容器

  将tracker运行目录映射到宿主机的/var/fdfs/tracker目录中

sudo docker run -dit --name=tracker --network=host -v /var/fdfs/tracker:/var/fdfs delron/fastdfs tracker 
delron/fastdfs 为镜像,可用sudo docker image ls 查看

3,开启storage 容器
sudo docker run -dit --name=storage --network=host -e TRACKER_SERVER=192.168.174.168:22122 -v /var/fdfs/storage:/var/fdfs delron/fastdfs storage

 

4,查看宿主机的映射路径

技术图片

5,DFS服务端配置好以后,进入Django项目进行配置服务端

  1,在环境中安装下面三个模块,第一个是已经下载好的模块,

技术图片

 

6,项目配置

cilent.config 配置文件内容如下,创建client.conf文件后,直接复制修改下面的配置就好

技术图片
# connect timeout in seconds
# default value is 30s
connect_timeout=30

# network timeout in seconds
# default value is 30s
network_timeout=60

# the base path to store log files
base_path=/Users/meihao/Desktop

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=172.16.238.128:22122

#standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info

# if use connection pool
# default value is false
# since V4.05
use_connection_pool = false

# connections whose the idle time exceeds this time will be closed
# unit: second
# default value is 3600
# since V4.05
connection_pool_max_idle_time = 3600

# if load FastDFS parameters from tracker server
# since V4.05
# default value is false
load_fdfs_parameters_from_tracker=false

# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V4.05
use_storage_id = false

# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V4.05
storage_ids_filename = storage_ids.conf


#HTTP settings
http.tracker_server_port=80

#use "#include" directive to include HTTP other settiongs
##include http.conf
View Code

 

技术图片

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

以上是关于docker 和 FastDFS上传和下载文件的主要内容,如果未能解决你的问题,请参考以下文章

Docker和FastDFS分布式文件系统

Docker安装FastDFS

手把手教你docker搭建fastDFS文件上传下载服务器

django中使用FastDFS分布式文件系统接口代码实现文件上传下载更新删除

Java实现FastDFS文件上传下载和删除

Java实现FastDFS文件上传下载和删除