一、背景
docker-compose适合单节点开发应用部署,部署方式简单、便捷。基础知识点参考文档《Docker基本应用说明v0.3.md》。其中官方文档说明:https://docs.docker.com/storage/volumes/
二、docker-compose管理容器
2.1创建映射目录
[root@xiangys0134-haddop01 data]# mkdir datagw/datagw_frame/profile -p
[root@xiangys0134-haddop01 data]# cd datagw/
2.2从容器中拷贝文件
[root@xiangys0134-haddop01 ~]# docker run -it registry.cn-hangzhou.aliyuncs.com/xunceprivate/public:datagw-v1.0.2 bash
#在另外一个shell窗口下执行
[root@xiangys0134-haddop01 ~]# name=(docker ps |grep datagw-v1.0.2|tail -1|awk '{print1}')
#拷贝配置文件目录,第一次运行docker-compose编排拷贝,后续直接修改配置文件即可
[root@xiangys0134-haddop01 datagw]# docker cp name:/etc/uvframe ./frame/profile
#拷贝数据库脚本,每次执行都需要拷贝一次
[root@xiangys0134-haddop01 datagw]# if [ -d script ]; then rm -rf script ; fi ;docker cpname:/data/DataGW/script .
#权限设置
[root@xiangys0134-haddop01 datagw]# chown -R datagw. frame/
2.3配置文件说明
通过hostpath文件映射至容器文件模式,本地修改frame目录下的配置文件即可
2.4docker-compose编排
[root@xiangys0134-haddop01 datagw]# vi docker-compose.yml
version: '3'
services:
datagw:
image: registry.cn-hangzhou.aliyuncs.com/xunceprivate/public:datagw-v1.0.2
container_name: datagw
ports:
- 12000:11000
- 12001:11000
volumes:
- ./frame/profile:/home/frame/profile
privileged: true
#restart: always
networks:
- xunce
networks:
xunce:
2.5启动容器
[root@xiangys0134-haddop01 datagw]# docker-compose up -d
[root@xiangys0134-haddop01 datagw]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------
datagw /usr/sbin/init Up 0.0.0.0:12001->11000/tcp,0.0.0.0:12000->11000/tcp
2.6docke-compose编排多个容器
略
三、数据库执行脚本
将script目录下sql脚本在数据库中运行
四、附
4.1数据网关和dc模块
version: '3'
services:
datagw:
image: registry.cn-hangzhou.aliyuncs.com/xunceprivate/public:datagw-v1.0.2
container_name: datagw
environment:
LD_PRELOAD: /lib64/libgssapi_krb5.so.2:/lib64/libkrb5.so.3:/lib64/libk5crypto.so.3:/lib64/libkrb5support.so.0
ports:
- 12000:11000
- 12001:11000
volumes:
- ./datagw_frame/profile:/home/frame/profile
- ./kafka:/usr/local/kafka
- ./kafka/krb5.conf:/etc/krb5.conf
command: ['/bin/bash','-c','echo -e "192.168.0.105 con01.xuncetech.com\n192.168.0.106 con02.xuncetech.com\n192.168.0.107 con03.xuncetech.com">>/etc/hosts ; /usr/bin/uvframe /etc/uvframe/datagwservice.xml']
#privileged: true
#restart: always
networks:
- xunce
dc:
image: registry.cn-hangzhou.aliyuncs.com/xunceprivate/public:DataCollect-v1.3.2
container_name: dc
environment:
LD_PRELOAD: /lib64/libgssapi_krb5.so.2:/lib64/libkrb5.so.3:/lib64/libk5crypto.so.3:/lib64/libkrb5support.so.0
#entrypoint: ['/bin/bash','-c','/usr/bin/uvframe /etc/uvframe/DataService.xml']
volumes:
- ./dc_frame/profile:/home/frame/profile
- ./bin/start.sh:/usr/lib/uvframe/start.sh
- ./kafka:/usr/local/kafka
- ./kafka/krb5.conf:/etc/krb5.conf
- ./dc_frame/profile/oracle.json:/etc/uvframe/oracle.json
#privileged: true
#restart: always
networks:
- xunce
networks:
xunce:
留言