如何在Postgres Docker-Compose启动时运行* .sh文件

时间:2019-01-19 16:54:52

标签: postgresql docker docker-compose

启动新的Docker-Compose Postgres映像时,我试图在Postgres上创建新的DB + User。由于某些原因,xSolvpa = vpa(xSol) ySolvpa = vpa(ySol) lims=[-1.1 1.5] fplot(xSolvpa, lims) hold on fplot(ySolvpa, lims) 文件未复制到容器上init-user-db.sh文件夹内。

知道为什么吗?

谢谢

docker-compose.yml:

docker-entrypoint-initdb.d

init-user-db.sh:

version: '3'
services:
  db:
    image: postgres:11
    volumes:
      - ./db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
    ports:
      - '5432:5432'

这是我收到的输出:

#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" <<-EOSQL
    CREATE USER bh_ideas_user;
    CREATE DATABASE bh_ideas ENCODING UTF8;
    GRANT ALL PRIVILEGES ON DATABASE bh_ideas TO bh_ideas_user;
    ALTER USER bh_ideas_user WITH PASSWORD 'password123';
    ALTER USER bh_ideas_user WITH SUPERUSER;
EOSQL

$ docker-compose up && exit 0 Creating ideas-api_db_1 ... done Attaching to ideas-api_db_1 db_1 | The files belonging to this database system will be owned by user "postgres". db_1 | This user must also own the server process. db_1 | db_1 | The database cluster will be initialized with locale "en_US.utf8". db_1 | The default database encoding has accordingly been set to "UTF8". db_1 | The default text search configuration will be set to "english". db_1 | db_1 | Data page checksums are disabled. db_1 | db_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok db_1 | creating subdirectories ... ok db_1 | selecting default max_connections ... 100 db_1 | selecting default shared_buffers ... 128MB db_1 | selecting dynamic shared memory implementation ... posix db_1 | creating configuration files ... ok db_1 | running bootstrap script ... ok db_1 | performing post-bootstrap initialization ... ok db_1 | syncing data to disk ... ok db_1 | db_1 | Success. You can now start the database server using: db_1 | db_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start db_1 | db_1 | db_1 | WARNING: enabling "trust" authentication for local connections db_1 | You can change this by editing pg_hba.conf or using the option -A, or db_1 | --auth-local and --auth-host, the next time you run initdb. db_1 | **************************************************** db_1 | WARNING: No password has been set for the database. db_1 | This will allow anyone with access to the db_1 | Postgres port to access your database. In db_1 | Docker's default configuration, this is db_1 | effectively any other container on the same db_1 | system. db_1 | db_1 | Use "-e POSTGRES_PASSWORD=password" to set db_1 | it in "docker run". db_1 | **************************************************** db_1 | waiting for server to start....2019-01-19 10:28:21.673 UTC [48] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2019-01-19 10:28:21.692 UTC [49] LOG: database system was shut down at 2019-01-19 10:28:21 UTC db_1 | 2019-01-19 10:28:21.699 UTC [48] LOG: database system is ready to accept connections db_1 | done db_1 | server started db_1 | db_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* db_1 | db_1 | 2019-01-19 10:28:21.763 UTC [48] LOG: received fast shutdown request db_1 | waiting for server to shut down....2019-01-19 10:28:21.766 UTC [48] LOG: aborting any active transactions db_1 | 2019-01-19 10:28:21.767 UTC [48] LOG: background worker "logical replication launcher" (PID 55) exited with exit code 1 db_1 | 2019-01-19 10:28:21.769 UTC [50] LOG: shutting down db_1 | 2019-01-19 10:28:21.794 UTC [48] LOG: database system is shut down db_1 | done db_1 | server stopped db_1 | db_1 | PostgreSQL init process complete; ready for start up. db_1 | db_1 | 2019-01-19 10:28:21.903 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 db_1 | 2019-01-19 10:28:21.903 UTC [1] LOG: listening on IPv6 address "::", port 5432 db_1 | 2019-01-19 10:28:21.910 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" db_1 | 2019-01-19 10:28:21.930 UTC [57] LOG: database system was shut down at 2019-01-19 10:28:21 UTC db_1 | 2019-01-19 10:28:21.937 UTC [1] LOG: database system is ready to accept connections 中,绑定已正确完成:

docker inspect

0 个答案:

没有答案