Docker容器:关系X在数据库中不存在

时间:2018-09-25 08:35:38

标签: postgresql docker exception docker-compose postgresql-initdb

我开发Java应用程序,使用docker创建数据库postgresql的图像。

我有一个文件夹“ docker-entrypoint-initdb.d”,其中包含用于创建表,数据的文件。

启动应用程序时,出现以下异常:org.postgresql.util.PSQLException:错误:关系“ myerp.sequence_comptable”不存在。

以下是docker-compose.yml的内容:

version: '2'
services:
  myerp.db:
    image: postgres:10
    ports:
      - "127.0.0.1:9032:5432"
    volumes:
       - "./init/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d"
    environment:
      - POSTGRES_DB=db_myerp
      - POSTGRES_USER=usr_myerp
      - POSTGRES_PASSWORD=myerp

当我启动命令docker时:

Creating network "dev_default" with the default driver
Creating dev_myerp.db_1 ... done
Attaching to dev_myerp.db_1
myerp.db_1  | The files belonging to this database system will be owned by user "postgres".
myerp.db_1  | This user must also own the server process.
myerp.db_1  |
myerp.db_1  | The database cluster will be initialized with locale "en_US.utf8".
myerp.db_1  | The default database encoding has accordingly been set to "UTF8".
myerp.db_1  | The default text search configuration will be set to "english".
myerp.db_1  |
myerp.db_1  | Data page checksums are disabled.
myerp.db_1  |
myerp.db_1  | fixing permissions on existing directory /var/lib/postgresql/data ... ok
myerp.db_1  | creating subdirectories ... ok
myerp.db_1  | selecting default max_connections ... 100
myerp.db_1  | selecting default shared_buffers ... 128MB
myerp.db_1  | selecting dynamic shared memory implementation ... posix
myerp.db_1  | creating configuration files ... ok
myerp.db_1  | running bootstrap script ... ok
myerp.db_1  | performing post-bootstrap initialization ... ok
myerp.db_1  | syncing data to disk ... ok
myerp.db_1  |
myerp.db_1  | Success. You can now start the database server using:
myerp.db_1  |
myerp.db_1  |     pg_ctl -D /var/lib/postgresql/data -l logfile start
myerp.db_1  |
myerp.db_1  |
myerp.db_1  | WARNING: enabling "trust" authentication for local connections
myerp.db_1  | You can change this by editing pg_hba.conf or using the option -A, or
myerp.db_1  | --auth-local and --auth-host, the next time you run initdb.
myerp.db_1  | waiting for server to start....2018-09-24 14:53:52.027 UTC [40] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myerp.db_1  | 2018-09-24 14:53:52.061 UTC [41] LOG:  database system was shut down at 2018-09-24 14:53:51 UTC
myerp.db_1  | 2018-09-24 14:53:52.069 UTC [40] LOG:  database system is ready to accept connections
myerp.db_1  |  done
myerp.db_1  | server started
myerp.db_1  | CREATE DATABASE
myerp.db_1  |
myerp.db_1  |
myerp.db_1  | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
myerp.db_1  |
myerp.db_1  | waiting for server to shut down....2018-09-24 14:53:52.541 UTC [40] LOG:  received fast shutdown request
myerp.db_1  | 2018-09-24 14:53:52.552 UTC [40] LOG:  aborting any active transactions
myerp.db_1  | 2018-09-24 14:53:52.555 UTC [40] LOG:  worker process: logical replication launcher (PID 47) exited with exit code 1
myerp.db_1  | 2018-09-24 14:53:52.559 UTC [42] LOG:  shutting down
myerp.db_1  | 2018-09-24 14:53:52.588 UTC [40] LOG:  database system is shut down
myerp.db_1  |  done
myerp.db_1  | server stopped
myerp.db_1  |
myerp.db_1  | PostgreSQL init process complete; ready for start up.
myerp.db_1  |
myerp.db_1  | 2018-09-24 14:53:52.657 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
myerp.db_1  | 2018-09-24 14:53:52.657 UTC [1] LOG:  listening on IPv6 address "::", port 5432
myerp.db_1  | 2018-09-24 14:53:52.667 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myerp.db_1  | 2018-09-24 14:53:52.696 UTC [58] LOG:  database system was shut down at 2018-09-24 14:53:52 UTC
myerp.db_1  | 2018-09-24 14:53:52.705 UTC [1] LOG:  database system is ready to accept connections
myerp.db_1  | 2018-09-24 14:57:16.551 UTC [68] ERROR:  relation "myerp.sequence_ecriture_comptable" does not exist at character 46
myerp.db_1  | 2018-09-24 14:57:16.551 UTC [68] STATEMENT:
myerp.db_1  |                   SELECT derniere_valeur FROM myerp.sequence_ecriture_comptable
myerp.db_1  |                   WHERE annee = $1 AND journal_code = $2

你能帮我吗?

谢谢

0 个答案:

没有答案