赞
踩
- mkdir -p /home/datasophon && cd /home/datasophon
- wget https://github.com/datavane/datasophon/releases/download/v1.2.0/datasophon-manager-1.2.0.tar.gz
- tar -zxvf datasophon-manager-1.2.0.tar.gz
- mkdir packages
- vim /home/datasophon/docker/datasophon-manager-1.2.0/conf/application.yml
-
- spring:
- datasource:
- type: com.alibaba.druid.pool.DruidDataSource
- url: jdbc:mysql://db:3306/datasophon?useUnicode=true&characterEncoding=utf-8
- username: username
- password: password
- driver-class-name: com.mysql.jdbc.Driver
由于docker的容器化本质上进程而不是虚拟机,所以原有启动脚本的nohuo会导致docker认为任务已经执行完毕,从而退出,故而需要修改
在startStop 的case方法中添加如下命令
- (start_docker)
- [ -w "$DDH_PID_DIR" ] || mkdir -p "$DDH_PID_DIR"
-
- if [ -f $pid ]; then
- if kill -0 `cat $pid` > /dev/null 2>&1; then
- echo $command running as process `cat $pid`. Stop it first.
- exit 1
- fi
- fi
-
- echo starting $command, logging to $log
-
- exec_command="$DDH_OPTS -classpath $DDH_CONF_DIR:$DDH_LIB_JARS $CLASS"
-
- echo "nohup $JAVA $exec_command > $log 2>&1 &"
- $JAVA $exec_command
- echo $! > $pid
- ;;
EXPOSE是容器暴露端口,理论容器间可以访问的情况下是无需暴露,此处是官方文档中提到的端口
- cat > dockerfile << EOF
- FROM centos7_jdk8:latest
- WORKDIR /datasophon
- RUN yum install lsof -y
- EXPOSE 8081
- EXPOSE 2551-2552
- EXPOSE 8586
- EXPOSE 9100
- EXPOSE 8888
- ENV TZ=Asia/Shanghai
- ENV LANG=zh_CN.UTF-8
- CMD ["/sbin/init"]
- CMD ["bin/datasophon-api.sh","start_docker","api"]
- EOF
通过挂在目录的方式将数据文件放到容器中,方便我们在宿主机上进行修改,但只暴露所需的8081端口到宿主机
- cat > build.sh << EOF
- #!/bin/bash
- docker stop datasophon
- docker rm datasophon
- docker rmi datasophon:v1.2.0
- docker build /home/datasophon/docker -t datasophon:v1.2.0
- docker run -it -d -v /home/datasophon/docker/datasophon-manager-1.2.0:/datasophon -v /home/datasophon/docker/packages:/opt/datasophon -p 8081:8081 --privileged --name datasophon datasophon:v1.2.0
- EOF
- chmod +x build.sh
- ./build.sh
访问 http://dockerhost:8081/ddh
后续已有打包好的docker-compose模式,将在下期发布,镜像已上传至阿里云(因为是私仓,所以下载速度和并发会有点拮据)
docker pull registry.cn-shanghai.aliyuncs.com/datasophon/datasophon:v1.2.0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。