Let’s Start Creating Docker Seeding
Hope you are familiar with “Docker-Compose”
├── docker-compose.yml (File)
├── docker_postgres_init.sql (File)
Create a new file docker-compose.yml
Above file, we have created a Postgres Docker container with Port No: 5432
As well as set environment variables such as default username, password of Postgres container.
if you check the entire file we have also created volumes that point to the `docker_postgres_init.sql` file.
- ./docker_postgres_init.sql:/docker-entrypoint initdb.d/docker_postgres_init.sql
The script inside “docker_postgres_init.sql” will create a new table student and insert the records as well
When you run the following command in the root directory for the project.
then you will see in the console docker_postgres_init.sql script will be executed as the following screenshot