如何使用Pry在Docker中调试Rails应用程序? [英] How to debug a rails app in docker with pry?

查看:80
本文介绍了如何使用Pry在Docker中调试Rails应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails应用程序在开发环境中的docker容器中运行。

I have a rails app running in a docker container in development environment.

当我尝试通过放置 binding.pry进行调试时,在代码中的某个位置并将其附加到容器上,我可以在输出中看到 pry 提示,但它不会暂停并且我不能

When I try to debug it with placing binding.pry somewhere in the code and attaching to the container I can see the pry prompt in the output but it doesn't pause on it and I can't interact with it like it was without docker container.

那么如何调试容器化的应用程序呢?

So how do I debug a containerized app?

推荐答案

如果使用的是docker-compose,则可以将这些标志添加到 docker-compose.yml

If you're using docker-compose, you can add these flags to docker-compose.yml:

app:
  tty: true
  stdin_open: true

,然后使用 docker attach project_app_1 附加到您的进程。 撬轨现在在这里工作。确保在容器上安装了 less 以获得最佳的撬动体验。

And then attach to your process with docker attach project_app_1. pry-rails works here now. Ensure less is installed on your container for the optimal pry experience.

cf。 https://github.com/docker/compose/issues/423#issuecomment-141995398

这篇关于如何使用Pry在Docker中调试Rails应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆