Connecting to Postgres from a Separate Container
Explore how to manually connect to a Postgres database running in a separate container using Docker Compose commands, verify connectivity, and configure your Rails app to use Postgres by updating the Gemfile and database settings.
Connecting to Postgres
As you become more and more comfortable with using Compose, you will find
that you trust it to do what you need. A quick docker-compose ps is probably all you need to verify that a service is running. However, since running services like Postgres inside a container is still fairly new for us, let’s take the extra step of manually connecting to it from a different container, just like we did with redis.
Starting the Postgres client
As was the case with redis, the postgres image comes preinstalled with psql, the Postgres client. This means we can piggyback on our new database service in order to run a one-off container, based on the postgres ...