简体   繁体   English

celery pdb 在 docker 容器内运行,并更改侦听端口

[英]celery pdb running inside docker container with changing listening port

Looking for advice on how I can run celery pdb inside my docker container while port forwarding so i can access from the outside world.寻求有关如何在端口转发时在 docker 容器内运行 celery pdb 的建议,以便我可以从外部世界访问。

I am following the guide at http://celery.readthedocs.org/en/latest/tutorials/debugging.html我正在遵循http://celery.readthedocs.org/en/latest/tutorials/debugging.html 上的指南

The issue I am facing is that even when I tell the container.我面临的问题是,即使我告诉容器。

-e CELERY_RDB_HOST='0.0.0.0' -e CELERY_RDB_PORT='6900' -p 6900:6900. -e CELERY_RDB_HOST='0.0.0.0' -e CELERY_RDB_PORT='6900' -p 6900:6900。

And get to the breakpoint in the app, the port that actually gets open is not what I asked for so my port forward no longer is valid.... Eg.并到达应用程序中的断点,实际打开的端口不是我要求的,因此我的端口转发不再有效......例如。 the port 6902 gets opened instead, and no matter what I ask the port to be, it changes again to not what I asked for.端口 6902 被打开了,无论我要求端口是什么,它都会再次更改为不是我要求的。

I know it chooses from a list of 100 ports that it deems 'available' but not sure how to get around this problem.我知道它从它认为“可用”的 100 个端口列表中进行选择,但不确定如何解决这个问题。 Any advise would be welcome.欢迎任何建议。

Thanks!谢谢!

You can run your container by specifying a range of ports (see http://docs.docker.com/reference/run/#expose-incoming-ports ):您可以通过指定一系列端口来运行容器(请参阅http://docs.docker.com/reference/run/#expose-incoming-ports ):

docker run -d -e CELERY_RDB_HOST='0.0.0.0' -p 6900-7000:6900-7000 celery

After that, when you hit your breakpoint, you just need to telnet into it:之后,当您遇到断点时,您只需要 telnet 进入它:

telnet localhost 6902

I've got the same issue, celery v4.4.7 in 11-2020.我遇到了同样的问题,celery v4.4.7 在 11-2020 中。 Whatever I set to enviroment variable CELERY_RDB_PORT, I'll always get that nuber +2.无论我为环境变量 CELERY_RDB_PORT 设置什么,我都会得到那个 nuber +2。 IE. IE。 If I set 9024, then rdb will listen on 9026.如果我设置了 9024,那么 rdb 将监听 9026。

Your docker command might look like this.您的 docker 命令可能如下所示。

CELERY_RDB_HOST='0.0.0.0' -e CELERY_RDB_PORT='6900' -p 6902:6902

It's probably celery's bug.这可能是芹菜的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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