Docker Postgres:9.4 , how to create schema in the bank once the container starts?

Asked

Viewed 475 times

0

Hello, all quiet folks ?

I’m messing with Docker-Compose configuring a system with Docker I’m mapping volumes with *.sh files in the directory /docker-entrypoint-initdb.d/to start basic settings for my database:

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 command

Docker-Compose up

he climbs the bank but does not create the schema someone could tell me where I am doing wrong ?

1 answer

0


I believe it is a ';' missing at the end of the SQL line, just after '...AUTHORIZATION Intelbras'. The Bank is waiting for the end of the statement. and does not perform, tested here and worked.

  • Tbm had thought about it, but found out that he was mapping a directory that had no file contained anything, put the *.sh file inside the directory and worked, thanks for the reply :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.