If you can use the official postgres image, or base your image on it, you can pass in a username and password as an environment variable when you docker run it. Like so:
docker run -it -e POSTGRES_PASSWORD=some_password postgres:9.4
You can also pass in POSTGRES_USER, POSTGRES_DB, and PGDATA, which is a file location where the database should store the data files.