Add Debugger in docker-compose/docker in ruby on rails Application

Total Blog Views: 109

Blog Status: publish

Created By: swazahmad Created at: 07-28-2021

Tags: ruby on rails debugger docker-compose

Debugging Rails App With Docker Compose

Please follow the Below steps, As per understadning your application is already Configured with docker

Modify GemFile

Add Byebug Gem In in your Gemfile.

Add debugger in rails, debugger docker-compose.yml 

 

Modify docker compose file

Add below Line in docker-compose.yml file 

 

web:
  ...
  stdin_open: true
  tty: true

 

After Modifying above file try to run below command

 

docker-compose up --build

 

Add debugger In any of the controller For example like below.

 

class UsersController < ApplicationController
    def index
        debugger
        @users = User.paginate(page: params[:page], per_page: 6)
    end
end

 

Then We need to attach the container that the rails web application is running

Then Open A new TAB CTRL+SHIFT+TAB and run below command to list the containers for our rails web apllication container

 

docker container ls

 

Here you will see the list of conatiner you need to Note the CONTAINER ID of backend app

 

CONTAINER ID   IMAGE                    COMMAND                  CREATED       STATUS       PORTS                                                  NAMES
8784a3142417   shadbox-backend_app       "docker-entrypoint.s…"   2 hours ago   Up 2 hours   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp              shadbox-backend_app_1 

 

 Just final step Run below command

 

docker container attach 8784a3142417 #Here You need to pass your container id

 

Now You can start Debugging your rails application using docker container using docker-compose


swazahmad

Swaz is Practice Lead of ROR Developer. he's a Blogger, Mentor, and Rubyst. He has expertise in Javascript also . he's highly skilled in designing, developing and testing web applications. He enjoys being challenged and interesting with projects that need him to



Comments



  • swazahmad | almost 4 years ago
    Awesome Information Thanks For Sharing
Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads