docker 创建 greenplum 客户端镜像

1、压缩导出 gp 服务端安装包 greenplum-db-4.3.8.2.tar.gz

docker 创建 greenplum 客户端镜像_第1张图片

2、创建 Dockerfile

# VERSION 0.1.0
# AUTHOR: Jiangmiao Guan
# DESCRIPTION: gp client
# BUILD: docker build --build-arg gp_path=greenplum-db-4.3.8.2.tar.gz --rm -t igg-gp-client:0.1.0 .


FROM centos:7

# agent environment variables
ENV GPHOME=/home/gp-client/greenplum-db-4.3.8.2
ENV PYTHONHOME=$GPHOME/ext/python
ENV PYTHONPATH=$GPHOME/lib/python
ENV PATH=$PATH:$GPHOME/bin
ENV LD_LIBRARY_PATH=$GPHOME/lib:$PYTHONHOME/lib:$LD_LIBRARY_PATH

#ARG gp_path=/home/gp-client/greenplum-db-4.3.8.2
ARG gp_path=NOT_SET
ADD $gp_path $GPHOME

COPY docker-entrypoint.sh /

RUN chmod -R +x /docker-entrypoint.sh && \
  chmod -R +x $GPHOME/bin

ENTRYPOINT ["/docker-entrypoint.sh"]

3、创建 docker-entrypoint.sh

#!/bin/bash

pgpss=~/.pgpass
if [ ! -f "$pgpss" ]; then
  chomd 600 "$pgpss"
fi

exec "$@"

4、创建免密登录文件 .pgpass

10.0.100.10:5432:*:guanjiangmiao:123456

10.0.100.10:5432 为 gp server 地址

guanjiangmiao:123456 为 gp 库账号

5、build gp-client image

docker build --build-arg gp_path=greenplum-db-4.3.8.2.tar.gz --rm -t gjm-gp-client:0.1.0 .

6、run gp client container

docker run -it --name "gjm-gp-client" -v /home/gp-client/.pgpass:/root/.pgpass --rm gjm-gp-client:0.1.0 /bin/bash -c "psql -d postgres -h 10.0.100.10-p 5432 -U guanjiangmiao"

你可能感兴趣的:(Greenplum,Docker)