Starting a Postgres Server
Explore how to add a Postgres database service to your Rails app with Docker Compose. Learn to configure environment variables securely, start the database in detached mode, and verify it is running, preparing your app for reliable data persistence.
We'll cover the following...
Postgres server
We want to run a Postgres server for our Rails app to use. The process is very
similar to adding Redis. In the previous chapter, we started by familiarizing ourselves with how to run the Redis server with docker run. However, now that we have had some experience with adding a service, we can jump straight to setting up Postgres directly with Compose.
Modification of docker-compose.yml
Let’s add Postgres to our docker-compose.yml file:
Explanation
We have defined a new database service using the official postgres image. We are relying on this image’s default CMD ...