dockerfile 创建pgsql镜像
FROM library/postgres
MAINTAINER wenbin.ouyang
#初始化PostgreSQL
ENV POSTGRES_USER root
ENV POSTGRES_PASSWORD root
ENV POSTGRES_DB noah
ADD ./noah_pgsql_init.sql /docker-entrypoint-initdb.d/
#容器运行时监听的端口
EXPOSE 5432
启动容器
docker build -f ./Dockerfile -t oy/pgsql:1.0.0 .
指定jdbc连接pgsql的模式
postgresql-> 9.3 及以前的版本指定方式
spring.datasource.url=jdbc:postgresql://localhost:5432/postgresql?searchpath=newschema
postgresql-> 9.4 及以后的版本指定方式
spring.datasource.url=jdbc:postgresql://localhost:5432/postgresql?currentSchema=newschema
执行建表语句中有主键自增语句就会报错
解决:
DROP SEQUENCE IF EXISTS "chart_sql_id_seq";
CREATE SEQUENCE "chart_sql_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
然后执行建表语句