psql is PostgreSQL’s lightweight command-line client. It runs inside the standard Postgres Docker container, letting you connect to a database and execute SQL without installing another SQL tool on the host. section 1.3 section 1.4
Connect from a Postgres container
Start a running container, then open an interactive psql session with `docker exec -it postgres psql -U postgres`. A successful connection displays a `postgres=#` prompt. Run `\conninfo` to inspect the database, user, socket, and port; run `\d` to list relations; enter `\q` to exit. section 1.4
Use psql for both SQL and backslash-prefixed meta-commands:
- Execute ordinary SQL statements against the connected PostgreSQL database. section 1.4
- Run `\?` to display the available meta-commands, which expose connection information, database objects, file-based data loading, and other operations. section 1.4
- Connect locally without entering a password when `docker exec` places psql inside a container configured to trust local Unix-socket connections. section 1.4
Listing 1.3 Connecting with psql
docker exec -it postgres psql -U postgres
Inspect the runnable command for opening psql inside a Postgres container. section 1.4


