You need to have the database running before you create the users. For this you need multiple processes. You can either start postgres in a subshell (&) in the shell script, or use a tool like supervisord to run postgres and then run any initialization scripts.
A guide to supervisord and docker https://docs.docker.com/articles/using_supervisord/