You may switch the version tag with your preferred one.
docker pull mangar/rails-pg:4.2.6
docker run -v `pwd`:/app mangar/rails-pg:4.2.6 bash -c "rails new ./ -d postgresql -f"
Replace the generated database.yml for this
The environment variables: DATABASE_HOST, DATABASE_USERNAME and DATABASE_PASSWORDare already defined into the image.
default: &default
adapter: postgresql
encoding: unicode
pool: 5
host: <%= ENV['DATABASE_HOST'] %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
production:
<<: *default
database: app_production
Bellow the docker compose with Postgres image working together with the Rails.
services:
image: mangar/rails-pg:4.2.6
command: bash -c "/bin/bash docker-start.sh"
volumes:
- .:/app
ports:
- "3000:3000"
links:
- postgres
postgres:
image: postgres:9.4
ports:
- "5432:5432"
The script bellow keep your databse updated and Rails running
#!/bin/bash
rm ./tmp/docker.pid
echo "[start] $(date)" >> ./tmp/docker.pid
# Clean up
rm -rf ./tmp/cache ./tmp/pids ./tmp/sessions ./tmp/sockets
# Setup
bundle install
sleep 5
rake db:create db:migrate db:seed
# Running
echo "[finish] $(date)" >> ./tmp/docker.pid
rails server -p 3000 -b '0.0.0.0'
Content type
Image
Digest
Size
397.6 MB
Last updated
over 7 years ago
docker pull mangar/rails-pg:5.2.2