I have a docker-compose script which starts a Postgres container and an app container like so
db:
image: postgres:10.6
restart: always
ports:
- 5432:5432
app:
image: test_app:latest
restart: always
depends_on:
- db
This all works fine and 'app' can talk to 'db'. However, the postgres server is in a basically unusable state as it has no configuration with regards to having databases, users, etc. setup (apart from the defaults). It appears that the recommended way of fixing this is to create your own 'db image' pulling from postgres and running some shell script to take care of business (and then your composition uses this image), but this seems very hacky and convoluted to me.
Does anyone have a better way of setting up a postgres server with a known configuration inside a docker-compose based system?