How to execute .SQL file in container with postgres?

0

With a container postgres:9.6 I'm trying to run a .sql file after the "upload" container for database creation and a table;

postgres:
image: postgres:9.6
volumes:
  - dados:/var/lib/postgresql/data
  - ./scripts:/scripts
  - ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
  - database

file init.sql within scripts :

create database urlshor;
\c urlshor

create table urls(
    'id' serial not null,
    'url' varchar(255) not null,
    'clicks' integer not null,
    'created_at' timestamp not null default current_timestamp;
);

No error is displayed when running docker-compose up postgres and when accessing the container the file init.sql is contained in docker-entrypoint-inidb.d/ but is not executed.

What else do I need to do to get the script to run?

    
asked by anonymous 11.06.2018 / 18:52

0 answers