How run a script inside docker container?

The file needs to be inside the container at the default location where docker exec puts you in. For the postgres:12.2 image, that’s simply root /. Find out with docker exec postgres-12.2 pwd