February 2019
Intermediate to advanced
240 pages
5h 25m
English
We want to run a Postgres server for our Rails app to use. The process is very similar to how we added Redis.
In the previous chapter, we started by familiarizing ourselves with how to run the Redis server with docker run. However, now that we’ve had some experience with adding a service, let’s take the safety wheels off and jump straight to setting up Postgres directly with Compose.
Let’s add Postgres to our docker-compose.yml file:
| | version: '3' |
| | |
| | services: |
| | |
| | web: |
| | build: . |
| | ports: |
| | - "3000:3000" |
| | volumes: |
| | - .:/usr/src/app |
| | |
| | redis: |
| | image: redis |
| | |
| » | database: |
| » | image: postgres |
| » | environment: |
| » | POSTGRES_USER: postgres |
| » | POSTGRES_PASSWORD: some-long-secure-password |
| » | POSTGRES_DB: myapp_development ... |