I have a Django app running in Docker container. I'd like to populate my Postgres -database with some data when I run docker-compose up. I tried writing a sql -file:
# sql/fill_tables.sql
INSERT INTO person(name, gender)
VALUES ('testUser', 'male');
This is my docker-compose.yml where I have added the sql to the volumes:
db:
image: postgres
volumes:
- ./data/db:/var/lib/postgresql/data
- ./sql/fill_tables.sql:/docker-entrypoint-initdb.d/fill_tables.sql
env_file: .env
environment:
- POSTGRES_DB=$DATABASE_NAME
- POSTGRES_USER=$DATABASE_USER
- POSTGRES_PASSWORD=$DATABASE_PASSWORD
container_name: postgres_db
This however doesn't do anything, the table in my database stays empty. How is this supposed to be done with Docker?