Docker Postgres: 9.4, how to create schema in the database as soon as the container starts?

0

Hello, all quiet people?

I am moving with docker-compose configuring a system with docker I am mapping volumes with * .sh files in the /docker-entrypoint-initdb.d/ directory to start the basic settings of my bank:

version: '3.1'

services:

  db:
    image: postgres:9.6
    ports: 
      - '5432:5432'
    environment:
      POSTGRES_DB: 'imn'
      POSTGRES_PASSWORD: 'intelbras'
      POSTGRES_USER: 'intelbras'
    volumes:
      - ./init:/docker-entrypoint-initdb.d/

Inside the init folder I have a * .sh script running to create the schema

#!/bin/bash
set -e

psql -v --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
    CREATE SCHEMA imn AUTHORIZATION intelbras
EOSQL

When I use the

  

docker-compose up

It goes up the bank but does not create the schema could someone tell me where I'm doing wrong?

    
asked by anonymous 21.06.2018 / 15:37

1 answer

0

I believe it's a ';' missing at the end of the SQL line, shortly after the '... AUTHORIZATION intelbras'. The Bank is waiting for the end of the instruction. and it does not run, I tested it here and it worked.

    
21.06.2018 / 16:51