Docker settings template for Rails + MySQL development
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Rails + MySQL environment settings for development.


  1. Copy this repository to project directory.
  2. Create and edit env file
cp common.env.sample common.env
# and edit
  1. Build.
docker-compose build
  1. Create Rails project on working directory of app.
docker-compose run --rm app rails new . --force --database=mysql --skip-bundle
# with Webpacker & React
docker-compose run --rm app rails new . --force --database=mysql --skip-bundle --webpack=react 
  1. Edit app/config/database.yml.
password: <%= ENV.fetch("MYSQL_ROOT_PASSWORD") %>
host: db
# and other settings like charset
  1. Install gems for Rails
docker-compose run --rm app bundle install
  1. Create db
docker-compose run --rm app rails db:create
  1. Up
docker-compose up
  1. Done


Adding gems

Updating Gemfile and docker-compose build doesn't work because image's bundle directory is hidden by the mounted volume when the container runs.
Do docker-compose run --rm app bundle install to install gems into the mounted volume.