欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

Postgres的docker-compose配置示例

时间:2023-07-10
base demo Dockerfile

FROM postgres:14ENV POSTGRES_USER postgresENV POSTGRES_PASSWORD postgresENV POSTGRES_DB postgresEXPOSE 15432

docker-compose

version: "3"services: postgres: build: context: ./docker_files/postgres/ dockerfile: Dockerfile container_name: postgres ports: - "15432:5432"




custom demo Dockerfile

FROM postgres:14ENV POSTGRES_USER kb_db_userENV POSTGRES_PASSWORD JX98#5%wsT^iENV POSTGRES_DB postgresCOPY ./init_files/init-user-db.sh /docker-entrypoint-initdb.d/ADD ./init_files/release.sql.gz /docker-entrypoint-initdb.d/EXPOSE 15432

init-user-db.sh

#!/bin/bashset -epsql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE DATAbase karbon_card_v1;EOSQL

docker-compose

version: "3"services: postgres: build: context: ./docker_files/postgres/ dockerfile: Dockerfile container_name: postgres ports: - "15432:5432"

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。