小编Sim*_*mon的帖子

Docker-Compose Postgresql导入转储

我有关于docker和postgres的问题.每次docker启动时我都要设置一个新的postgres数据库并想要导入给定的转储.

我的问题就像,但答案对我来说还不够:Docker postgres不会在docker-entrypoint-initdb.d中运行init文件

多克尔 - 撰写:

postgres:
  environment:
   - POSTGRES_USER=****
   - POSTGRES_PASSWORD=****
   - POSTGRES_DB=****
build:
  context: .
  dockerfile: dockerfile-postgres
Run Code Online (Sandbox Code Playgroud)

我的Dockerfile :(我已经尝试使用.sh结尾的脚本)

FROM postgres
ADD dump.sql /docker-entrypoint-initdb.d/
Run Code Online (Sandbox Code Playgroud)

根据https://hub.docker.com/_/postgres/ dump.sql必须用于导入数据库.

使用docker启动应用程序只会给出:

postgres_1     | LOG:  invalid record length at 0/1708600
postgres_1     | LOG:  redo is not required
postgres_1     | LOG:  MultiXact member wraparound protections are now enabled
postgres_1     | LOG:  database system is ready to accept connections
postgres_1     | LOG:  autovacuum launcher started
Run Code Online (Sandbox Code Playgroud)

除了我测试我的数据库是否已导入,我的数据库中没有表.我做错了什么(文件在目标系统上读取和执行)?用psql导入它没问题,所以我的转储是正确的.

我希望你能帮助我,我想提前感谢你.

postgresql docker docker-compose

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

docker ×1

docker-compose ×1

postgresql ×1