Docker template for Rails app or Rails + MySQL development.
- Ruby 2.5.0
- Rails 5.2.0
- MySQL 5.7
- Copy env.sample to .env and edit the .env
$ cp .env.sample .env
- Run following command
$ docker-compose run app rails new . --force --database=mysql --skip-bundle
- Modify config/database.yml as following
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password: xxxxxx # <- Modify here.
host: db # <- Modify here.
- Run
docker-compose up -d
- Finally, you need to create the database. Run
docker-compose run app bin/rake db:create
To stop container then run following command
$ docker-compose stop
To start container again then run following command
$ docker-compose start