fastdfs 构建docker镜像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了fastdfs 构建docker镜像相关的知识,希望对你有一定的参考价值。
目录结构[root@fastdfs]# tree .
.
├── conf
│?? ├── client.conf
│?? ├── http.conf
│?? ├── mime.types
│?? ├── mod_fastdfs.conf
│?? ├── nginx.conf
│?? ├── storage.conf
│?? └── tracker.conf
├── Dockerfile
├── fastdfs.sh
└── source
├── fastdfs-nginx-module.tar.gz
├── fastdfs.tar.gz
├── libfastcommon.tar.gz
└── nginx-1.15.4.tar.gz
2 directories, 13 files
编写dockerfile,可以自定义启动项目
FROM centos:7.7.1908
LABEL app.maintainer=foxchan
LABEL app.version="v6.06"
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo ‘Asia/Shanghai‘ >/etc/timezone
ENV libfastcommon V1.0.43
ENV fastdfs V6.06
ENV fastdfs-nginx-module V1.22
ADD fastdfs.sh /home
ADD source/libfastcommon.tar.gz /usr/local/src/
ADD source/fastdfs.tar.gz /usr/local/src/
ADD source/fastdfs-nginx-module.tar.gz /usr/local/src/
ADD source/nginx-1.15.4.tar.gz /usr/local/src/
# run
RUN yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y && mkdir -p /data/dfs/{tracker,storage} && cd /usr/local/src/ && cd libfastcommon-1.0.43/ && ./make.sh && ./make.sh install && cd ../ && cd fastdfs-6.06/ && ./make.sh && ./make.sh install && cd ../ && cd nginx-1.15.4/ && ./configure --add-module=/usr/local/src/fastdfs-nginx-module-1.22/src/ && make && make install && chmod +x /home/fastdfs.sh
VOLUME /etc/fdfs
VOLUME /data/dfs
ENTRYPOINT /home/fastdfs.sh && /bin/bash
启动脚本
#!/bin/bash
#Date: 2020-03-11
#Writer: foxchan
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.t
cp /etc/fdfs/nginx.conf /usr/local/nginx/conf
if [ "$role" == "tracker" ];then
echo "start trackerd"
/etc/init.d/fdfs_trackerd start
elif [ "$role" == "storage" ];then
echo "start storaged"
/etc/init.d/fdfs_storaged start
echo "start nginx"
/usr/local/nginx/sbin/nginx
else
echo -e "Usage: role [tracker | storage]"
fi
启动命令
docker run -dit --net=host -e role=tracker -v /data/dfs/conf:/etc/fdfs/ -v /data/dfs:/data/dfs --name tracker fastdfs:v6.06
docker run -dit --net=host -e role=storage -v /data/dfs/conf:/etc/fdfs/ -v /data/dfs:/data/dfs --name storage fastdfs:v6.06
以上是关于fastdfs 构建docker镜像的主要内容,如果未能解决你的问题,请参考以下文章