Are you going to containerize the whole app or just Postgres? I’m asking because I’m doing local Rails development (I’m basically kinda containerizing gems and whatnot with rbenv already, so I don’t see any need to containerize the whole app), but I still containerize Postgres in development environments to avoid having running services on my main laptop. Because of this, I’m not using docker-compose or even a Dockerfile, only this: podman run --name app_db -p 5432:5432 -d -e POSTGRES_PASSWORD=password docker.io/postgres:12-alpine
(I’m using podman instead of Docker, but it shouldn’t matter in this case). To make the container accept bin/rails db:create
and such without hassle, I add a postgres role podman exec -it app_db bash -lc 'su - postgres -c "createuser --superuser YOURLOCALUSERNAME"'
. With Docker, maybe this user should be called “root” since it’s running as superuser.
If you’re going to dockerize the entire Rails app, then that’s a different ballgame. 