How to Dockerize Rails Application: Compose and Rails Tutorial
Every day, a curious developer and tech enthusiast never misses an opportunity to learn something new! This desire to study is something I understand. So, with your curiosity in mind, we're back with another Rails tutorial on using Docker Compose to a dockerize rails app. I hope you're familiar with what Docker is and why we need it.
Let's get started on developing and dockerizing the app.
Create a Rails App
Prerequisites: Dockerize Rails Application
As we are implementing Docker Compose, make sure about the following installations before getting started.
Install Docker Community Edition
Install Docker Compose
Create a Dockerfile for rails developer
Define Services Using Docker Compose
Build the Project
Database Connection
Summary: How to Dockerize Rails Application
mkdir ~/projects/noteapp
cd ~/projects/noteapp
Create Gemfile and empty Gemfile.lock (content is given above)
Create Dockerfile (content is given above)
Create docker-compose.yml (content is given above)
docker-compose run app rails new . āforce ādatabase=mysql
Make changes in config/database.yml
docker-compose build
docker-compose up
http://localhost:3001
docker-compose run ārm app rails g scaffold note title body:text
docker-compose run ārm app rake db:migrate
http://localhost:3001/notes
Read More in detail about: How to Dockerize Rails Application
















