I need to configure Postogres with some SQL commands, but everything I put in the /docker-entrypoint-initdb.d folder doesn't get executed. I'm using the postgres:9.6 image.
My Dockerfile is as follows:
FROM postgres:9.6
COPY init.sql /docker-entrypoint-initdb.d/
USER root
RUN chown postgres:postgres /docker-entrypoint-initdb.d/init.sql
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["postgres"]
I tried multiple commands in init.sql, for example:
CREATE DATABASE db_name;
Finally, this is the part of the yaml file that concerns the database.
db:
image: postgres-am
ports:
- target: 5432
published: 5432
protocol: tcp
mode: host
environment:
POSTGRES_PASSWORD: "postgres"
PGDATA: "/var/lib/postgresql/data/pgdata"
volumes:
- db_data:/var/lib/postgresql/data