I do not want to enter psql for input
You can simply use the built-in container initialization mechanism:
COPY init.sql /docker-entrypoint-initdb.d/10-init.sql
This ensures that your sql will be executed after the database server loads correctly.
script. psql /docker-entrypoint-initdb.d/ , .sh, .sql .sql.gz.
10- , ASCII. , , 20-create-tables.sql 30-seed-tables.sql.gz, , .
, . , , , docker-compose, .sql DB.
, build. Docker Compose , , , build, init, /docker-entrypoint.sh docker, /docker-entrypoint-initdb.d/.