docker-compose启动达梦数据库(dm7)

1. docker-compose文件

version: "3.1"
services:
  dm7:
    image: harbocto.xxx.com.cn/public/dm7
    environment:
      DM_DBA_PASSWORD: Boe888888
      TZ: Asia/Shanghai
    restart: always
    ports:
      - 5236:5236
    volumes:
      - /etc/hosts:/etc/hosts
      - ./dmdbms:/opt/dmdbms
      - ./start.sh:/root/start.sh

镜像公网上用的flobit/dm7

2. start.sh文件

复制这个文件出来主要是为了添加一条修改目录权限的命令,以便于持久化存储
容器启动挂载时直接创建的目录root权限,初始化的时候不成功。

#!/bin/bash
_start(){
    export DM_HOME="/opt/dmdbms"
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/dmdbms/bin"
    # 添加下边这条命令
    chown dmdba.dinstall /opt/dmdbms -R
    /opt/dmdbms/bin/dmserver /opt/dmdbms/data/DAMENG/dm.ini
}

_install(){
    #seting DBA_PASSWORD
    if [ -z "$DM_DBA_PASSWORD" ]; then
        DM_DBA_PASSWORD='strongP@ssW0rd'
    fi
    sed -i s/'{DM_DBA_PASSWORD}'/"$DM_DBA_PASSWORD"/g /tmp/DMInstall/install/dm_install.xml
    /bin/bash /tmp/DMInstall/install/myinstall.sh
}

if [ -d "/tmp/DMInstall" ];
then
    _install
    _start
else
    _start
fi;

3. 启动

[root@dev-python test2]# docker-compose up -d
Creating network "test2_default" with the default driver
Creating test2_dm7_1 ... done
[root@dev-python test2]# docker-compose ps
  Name               Command            State           Ports
-----------------------------------------------------------------------
test2_dm7_1   /bin/bash /root/start.sh   Up      0.0.0.0:5236->5236/tcp

posted on 2021-11-03 17:12  运维开发玄德公  阅读(135)  评论(0编辑  收藏  举报  来源

导航