简体   繁体   中英

How to debug rails application which is running inside docker container

I am trying to execute debugger in rails application which uses docker.Our application server executes in Ubuntu terminal using: docker-compose up . I did not find the way to run the debugger. We can't use rails s --debugger. What's the way to debug our rails application which is integrated with docker. When I keep debugger in application file we get output in console: {***** Debugger requested, but was not available (ensure ruby-debug is listed in Gemfile/installed as gem): Start server with --debugger to enable ***** }

I don't know ruby or rails, but this is general "problem" with docker-compose up . The code execution will not stop in a running container in this case and instead fail when you hit a point for the debugger. You need to run the service in the foreground instead:

docker-compose stop <my-service-to-debug>
docker-compose run --service-ports <my-service-to-debug> 

This will drop you into the debugger once your code hits that point. The important part here is the --service-ports flag which makes sure the same ports are exposed as you specified in your docker-compose.yml file. You can also use the --no-deps flag in case you don't want any linked containers to restart.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM