守护进程启动后停靠

我有一个小Gunicorn服务。 这是我的Dockerfile

 FROM ubuntu:16.04 RUN apt-get clean && apt-get update && apt-get install -y locales RUN locale-gen en_US.UTF-8 RUN update-locale LANG=en_US.UTF-8 LC_MESSAGES=POSIX RUN apt-get update \ && apt-get -y upgrade \ && apt-get install -y python-pip \ && mkdir /app ADD . app WORKDIR /app RUN pip install -r requirements.txt CMD ["/usr/local/bin/gunicorn", "--config", "/app/gunicorn.py", "myrun:app", "&&", "tail", "-f", "/dev/null"] 

问题是我不能把容器当作活动进程。 我这样运行: docker run --name pypypy -td -p 8187:8081 pytest

我做错了什么? 我读了一些post在stackoverflow。 但它不适用于我,我不知道为什么。

您是否决定添加&& tail -f /dev/null或者是从另一个Dockerfile示例复制的? 我的假设是,这是试图将tail作为活动进程,在后台启动gunicorn之后永远等待在空设备上?

无论如何,我敢肯定这是一个不必要的添加,如果你的目的只是为了一个单gunicorn进程的容器内运行gunicorn 。 例如, 这个主题的博客文章似乎显示gunicorn运行在一个容器内的非守护进程很好。 你可能能够得到&& tail..方法,但是我认为只要运行gunicorn进程就可以实现更清洁,也许为了更多的“Docker最佳实践”alignment,使用该博客文章中的日志logging设置, docker logs适合您的集装箱gunicorn过程。