from fdfs-base:5.11, starting fastdfs tracker service
83
the docker file : #This dockerfile uses the centos:7 image
FROM fdfs-base:5.11
ENV FDFS_LOG_DIR="/data/fdfs/logs"
COPY ./entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
USER docker
VOLUME ["/data/fdfs", "/etc/fdfs"]
EXPOSE 23000
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["tracker"]
the entrypoint.sh is : #!/bin/bash #define variable fdfs_ps=0 command_bin="" conf_file="" log_file="" export TOP_PID=$$ trap 'exit 1' TERM
#exit
function exit_script() {
kill -s TERM $TOP_PID
}
#accoding 1th parameter, swith into tracker or storage model if [ "$1" == "tracker" ]; then command_bin="/usr/bin/fdfs_trackerd" conf_file="/etc/fdfs/tracker.conf"; log_file="trackerd.log" echo "running in fdfs tracker modle" elif [ "$1" == "storage" ]; then command_bin="/usr/bin/fdfs_storaged" conf_file="/etc/fdfs/storage.conf"; log_file="storaged.log" echo "running in fdfs storage modle" else echo "error:unkown model, model : tracker||storage" exit_script fi
#checking configuration file if [ ! -f $conf_file ]; then echo "error: configuration file : $conf_file not existed" exit_script fi
#running service
command_str="$command_bin $conf_file"
echo " excute command is : $command_str "
$command_str
sleep 2
fdfs_ps=$(ps -ef|grep $command_bin | awk '{ if($8!="grep") print $2}')
if [ -n "$fdfs_ps" ];then
echo "$command_bin is running, pid: $fdfs_ps"
else
echo "error: $command_bin not running"
exit_script
fi
#checking logging file if [ ! -f "$FDFS_LOG_DIR/$log_file" ]; then echo "error: $FDFS_LOG_DIR/$log_file can not be found" kill $fdfs_ps exit_script fi
tail -f $FDFS_LOG_DIR/$log_file
docker running command:
docker run -d --name fdfs-tracker
--net=host
-v /data/fdfs/tracker/conf/:/etc/fdfs/
-v /data/fdfs/tracker/mnt/:/data/fdfs
fdfs-tracker:5.11
Content type
Image
Digest
Size
111.5 MB
Last updated
almost 8 years ago
docker pull bomb/fdfs-tracker:5.11