docker cp copies files between the host and a container in either direction, writing container:path for the container side. The daemon reads the container's filesystem directly, so it needs no tools in the image and works on stopped containers too. From the directory holding your booknest project, copy BookNest's schema in, apply it, add one of the six books, and bring a data dump back out:
docker cp booknest/db/schema.sql l3-postgres:/tmp/schema.sql
docker exec l3-postgres psql -U booknest -f /tmp/schema.sql
docker exec l3-postgres psql -U booknest -c "INSERT INTO books VALUES (3, 'Salt and Saffron', \
'Priya Nair', 'Cooking', 24, 4.8, 256, 2023, false, 'Coastal recipes')"
docker exec l3-postgres sh -c 'pg_dump -U booknest --data-only -t books > /tmp/books.sql'
docker cp l3-postgres:/tmp/books.sql .
grep '^3' books.sql | tr '\t' ','CREATE TABLE INSERT 0 1 3,Salt and Saffron,Priya Nair,Cooking,24.00,4.8,256,2023,f,Coastal recipes
tr shows the dump's tab-separated row with commas. The sh -c wrapper makes the > redirection happen inside the container; without it, your host shell would redirect instead. Use docker cp for one-off jobs such as extracting a crash dump. Files BookNest needs at every start belong in its image (BookNest Dockerfile), and data that must outlive the container belongs in a volume (Volumes, Bind Mounts and tmpfs).