ryanwi / rails7-on-docker

Working Rails 7 demo application running in Docker. No node.js or webpack required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Postgres doesn't seem to be running

carltonsmith opened this issue · comments

After running docker compose up I get the following, which looks good

myapp-db-1   | 2023-04-22 23:25:32.351 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
myapp-db-1   | 2023-04-22 23:25:32.352 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
myapp-db-1   | 2023-04-22 23:25:32.352 UTC [1] LOG:  listening on IPv6 address "::", port 5432
myapp-db-1   | 2023-04-22 23:25:32.357 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
myapp-db-1   | 2023-04-22 23:25:32.369 UTC [30] LOG:  database system was shut down at 2023-04-22 23:25:21 UTC
myapp-db-1   | 2023-04-22 23:25:32.376 UTC [1] LOG:  database system is ready to accept connections

The docker compose run web bash gets me a command prompt in the container as expected, but then

root@096698665a88:/usr/src/app# bin/rails db:create
could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Couldn't create 'myapp_development' database. Please check your configuration.
bin/rails aborted!
ActiveRecord::ConnectionNotEstablished: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?


Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tasks: TOP => db:create
(See full trace by running task with --trace)