...

/

Connecting to Postgres from a Separate Container

Connecting to Postgres from a Separate Container

We will see how we can connect our database to our Rails app.

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 ...