环境准备
所需全部环境配置文件已上传至群中,通过首页扫码加群下载即可
- libfastcommon.tar.gz
- fastdfs-5.11.tar.gz
- nginx-1.13.6.tar.gz
- fastdfs-nginx-module_v1.16.tar.gz
创建工作目录
在 Linux 服务器上创建 /usr/local/docker/fastdfs/environment 目录
mkdir -p /usr/local/docker/fastdfs/environment
说明:
- /usr/local/docker/fastdfs:用于存放 docker-compose.yml 配置文件及 FastDFS 的数据卷
- /usr/local/docker/fastdfs/environment:用于存放 Dockerfile 镜像配置文件及 FastDFS 所需环境
docker-compose.yml
version: '3.1' services: fastdfs: build: environment restart: always container_name: fastdfs volumes: - ./storage:/fastdfs/storage network_mode: host
environment中各种配置文件说明
Dockerfile
FROM ubuntu:xenial MAINTAINER topsale@vip.qq.com # 更新数据源 WORKDIR /etc/apt RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse' > sources.list RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse' >> sources.list RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse' >> sources.list RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse' >> sources.list RUN apt-get update # 安装依赖 RUN apt-get install make gcc libpcre3-dev zlib1g-dev --assume-yes # 复制工具包 ADD fastdfs-5.11.tar.gz /usr/local/src ADD fastdfs-nginx-module_v1.16.tar.gz /usr/local/src ADD libfastcommon.tar.gz /usr/local/src ADD nginx-1.13.6.tar.gz /usr/local/src # 安装 libfastcommon WORKDIR /usr/local/src/libfastcommon RUN ./make.sh && ./make.sh install # 安装 FastDFS WORKDIR /usr/local/src/fastdfs-5.11 RUN ./make.sh && ./make.sh install # 配置 FastDFS 跟踪器 ADD tracker.conf /etc/fdfs RUN mkdir -p /fastdfs/tracker # 配置 FastDFS 存储 ADD storage.conf /etc/fdfs RUN mkdir -p /fastdfs/storage # 配置 FastDFS 客户端 ADD client.conf /etc/fdfs # 配置 fastdfs-nginx-module ADD config /usr/local/src/fastdfs-nginx-module/src # FastDFS 与 Nginx 集成 WORKDIR /usr/local/src/nginx-1.13.6 RUN ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src RUN make && make install ADD mod_fastdfs.conf /etc/fdfs WORKDIR /usr/local/src/fastdfs-5.11/conf RUN cp http.conf mime.types /etc/fdfs/ # 配置 Nginx ADD nginx.conf /usr/local/nginx/conf COPY entrypoint.sh /usr/local/bin/ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] WORKDIR / EXPOSE 8888 CMD ["/bin/b
entrypoint.sh
#!/bin/sh /etc/init.d/fdfs_trackerd start /etc/init.d/fdfs_storaged start /usr/local/nginx/sbin/nginx -g 'daemon off;'
注:Shell 创建后是无法直接使用的,需要赋予执行的权限,使用
chmod +x entrypoint.sh
tracker.conf
FastDFS 跟踪器配置,容器中路径为:/etc/fdfs,修改为:
# is this config file disabled # false for enabled # true for disabled disabled=false # bind an address of this host # empty for bind all addresses of this host bind_addr= # the tracker server port port=22122 # 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 data and log files base_path=/fastdfs/tracker # max concurrent connections this server supported max_connections=256 # accept thread count # default value is 1 # since V4.07 accept_threads=1 # work thread count, should <= max_connections # default value is 4 # since V2.00 work_threads=4 # min buff size # default value 8KB min_buff_size = 8KB # max buff size # default value 128KB max_buff_size = 128KB # the method of selecting group to upload files # 0: round robin # 1: specify group # 2: load balance, select the max free space group to upload file store_lookup=2 # which group to upload file # when store_lookup set to 1, must set store_group to the group name store_group=group2 # which storage server to upload file # 0: round robin (default) # 1: the first server order by ip address # 2: the first server order by priority (the minimal) # Note: if use_trunk_file set to true, must set store_server to 1 or 2 store_server=0 # which path(means disk or mount point) of the storage server to upload file # 0: round robin # 2: load balance, select the max free space path to upload file store_path=0 # which storage server to download file # 0: round robin (default) # 1: the source storage server which the current file uploaded to download_server=0 # reserved storage space for system or other applications. # if the free(available) space of any stoarge server in # a group <= reserved_storage_space, # no file can be uploaded to this group. # bytes unit can be one of follows: ### G or g for gigabyte(GB) ### M or m for megabyte(MB) ### K or k for kilobyte(KB) ### no unit for byte(B) ### XX.XX% as ratio such as reserved_storage_space = 10% reserved_storage_space = 10% #standard log level as syslog, case insensitive, value list: ### emerg for emergency ### a