$ docker run --rm -p54321:5432 --name pgtestdb -e POSTGRES_PASSWORD=FooBar -d postgres:13 # wait a few seconds for it to start $ echo "CREATE USER $USER PASSWORD 'BarFoo'; CREATE DATABASE testing; GRANT ALL PRIVILEGES ON DATABASE testing TO $USER;" | psql postgresql://postgres:FooBar@localhost:54321 $ psql postgres://localhost:54321/testing # log in and create the above table # run the above Perl script $ PGPASSWORD=BarFoo psql postgres://localhost:54321/testing -c 'SELECT * FROM students' $ docker stop pgtestdb