Skip to Content
Docker for Rails Developers
book

Docker for Rails Developers

by Rob Isenberg
February 2019
Intermediate to advanced
240 pages
5h 25m
English
Pragmatic Bookshelf
Content preview from Docker for Rails Developers

Starting a Postgres Server

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Adam Notodikromo
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao

Publisher Resources

ISBN: 9781680506730Errata Page