Resi Dwi Thawasa

TIL

Pipe a .sql dump into a Postgres container

Needed to load a SQL dump into Postgres running under docker compose. The obvious pipe:

cat dump.sql | docker compose exec -T db psql -U postgres -d mydb

The part people miss is -T. By default docker compose exec allocates a pseudo-TTY, and that breaks the pipe so psql gets nothing useful. -T disables the TTY and the stdin pipe goes through cleanly.

Without it I kept getting an empty import and no clear error. With it, the dump loads fine.

#postgres #docker