How to build a Ruby on Rails development environment with Docker (Rails 6.x)

With reference to Docker official procedure, we will explain in detail the procedure for building a Docker development environment on Rails 6 series.

A detailed explanation of each command is explained in Procedures in Rails 5 series that I wrote earlier, so I will omit it in this article.

Create a Rails project

$ docker-compose run web rails new . --force --no-deps --database=mysql

Build container

$ docker-compose build

Modify database files

After executing the above, modify the config / database.yml file completely as follows.

config/database.yml


default: &default
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password:
  host: localhost

development:
  <<: *default
  database: myapp_development
  host: db
  username: root
  password: password

test:
  <<: *default
  database: myapp_test
  host: db
  username: root
  password: password

Create database

$ docker-compose run web rails db:create

Install Webpacker

Since Webpacker is required from Rails 6 series, install webpacker in the container of the web server.

$ docker-compose run web rails webpacker:install 

Start container with docker-compose

$ docker-compose up -d

Access and confirm startup

Access ** localhost: 3000 ** from your browser and check that the Rails initial screen is displayed.

image.png

Stop container

Use docker-compose to stop the container after validation.

$ docker-compose down

Recommended Posts

How to build a Ruby on Rails development environment with Docker (Rails 6.x)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Steps to build a Ruby on Rails development environment with Vagrant
How to build Rails 6 environment with Docker
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a development environment to create Ruby on Jets + React apps with Docker
[Rails] How to build an environment with Docker
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Build a Ruby on Rails development environment on AWS Cloud9
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
How to install Pry after building Rails development environment with Docker
Build a development environment where Ruby on Rails breakpoints work on Windows
How to build Rails + Vue + MySQL environment with Docker [2020/09 latest version]
Build a development environment for Docker + Rails6 + Postgresql
Introducing Rspec with Ruby on Rails x Docker
Build a WordPress development environment quickly with Docker
How to build a Pytorch environment on Ubuntu
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
I tried to build a Firebase application development environment with Docker in 2020
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
How to build docker environment with Gradle for intelliJ
Docker the development environment of Ruby on Rails project
How to build an environment with Docker, which is the minimum required to start a Rails application
How to build Java development environment with VS Code
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Try to build a Java development environment using Docker
A memorandum when building an environment with Ruby3.0 x Rails6.1 x Docker x CentOS Stream
How to use Ruby on Rails
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build Unity development environment on docker
I made a development environment with rails6 + docker + postgreSQL + Materialize.
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
How to display a graph in Ruby on Rails (LazyHighChart)
Build a Node-RED environment with Docker to move and understand
I tried to create a padrino development environment with Docker
Docker command to create Rails project with a single blow in environment without Ruby
[Rails] How to use rails console with docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
[Ruby] Building a Ruby development environment on Ubuntu
Build a Java development environment on Mac
[Ruby on Rails] How to use redirect_to
[Ruby on Rails] How to use kaminari
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Build a simple Docker + Django development environment
Ruby on Rails --From environment construction to simple application development on WSL2
I want to add a browsing function with ruby on rails
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ MySQL edition ~
Build a development environment for Django + MySQL + nginx with Docker Compose
Create a development environment for Ruby 3.0.0 and Rails 6.1.0 on Ubuntu 20.04.1 LTS
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Sequelize ~
One file of Docker x Laravel threat! Build a local development environment with the minimum configuration
How to create a query using variables in GraphQL [Using Ruby on Rails]
Build a Laravel / Docker environment with VSCode devcontainer