Gunicorn:在Docker和Dash Python上找不到命令
我最近使用Docker开发了一个Dash Python Dashboard Web应用程序,我想部署它。 (它在开发中正常工作)。 由于烧瓶不稳定用于部署,因此我决定改用枪支。
我在需求中添加了枪支。 我已经替换了Python App.py
Gunicorn App:Server 在初始脚本中。而且我已经重建了Docker-Compose以安装新图像。
但是我得到了错误gunicorn:找不到命令
。 看来枪支的道路有一个问题,但我不知道该如何解决。
这是名为container_api
的容器的dockerfile:
FROM archlinux:latest
COPY api/requirements.txt ./
RUN pacman-db-upgrade \
&& pacman -Syyu --noconfirm \
&& pacman -S python --noconfirm \
&& pacman -S python-pip --noconfirm \
&& pip install --no-cache-dir -r requirements.txt
WORKDIR /app
CMD chmod a+x entrypoint.sh && ./entrypoint.sh
这是entrypoint.sh:
#!/bin/bash
gunicorn app:server
我指定我在主机和容器之间有一个共享卷app
。因此,容器可以访问entrypoint.sh。 容器的日志显示: container_api | ./ entrypoint.sh:第3行:gunicorn:找不到命令
我还添加了docker-compose文件以查看容器的构建方式:
version: "3"
services:
worker:
build:
dockerfile: ./worker/Dockerfile
container_name: container_worker
environment:
- PYTHONUNBUFFERED=1
volumes:
- ./api:/app/
- ./worker:/app2/
api:
build:
dockerfile: ./api/Dockerfile
container_name: container_api
volumes:
- ./api:/app/
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "${API_PORT}:8050"
depends_on:
- worker
很奇怪的是,当我将烧瓶用作开发服务器时,我已经有了使用我的dash应用中通过remirent.txt安装的软件包没有问题。似乎在Dash应用程序之外使用软件包(在入口点脚本中)正在遇到问题。你知道为什么吗?
我希望我的解释很清楚。感谢您的帮助,
I've recently developped a Dash Python Dashboard web app using Docker and I want to deploy it. (it's working perfectly in development).
Since Flask is not stable for deployment, I decided to use gunicorn instead.
I've added gunicorn in the requirements.txt.
I've replaced python app.py
by gunicorn app:server
in the initial script. And I've rebuilt the docker-compose to install the new image.
But I get the error gunicorn: command not found
.
It seems that there is an issue with the path of gunicorn but I don't know how to solve it.
Here is the Dockerfile of the container named container_api
:
FROM archlinux:latest
COPY api/requirements.txt ./
RUN pacman-db-upgrade \
&& pacman -Syyu --noconfirm \
&& pacman -S python --noconfirm \
&& pacman -S python-pip --noconfirm \
&& pip install --no-cache-dir -r requirements.txt
WORKDIR /app
CMD chmod a+x entrypoint.sh && ./entrypoint.sh
Here is the entrypoint.sh:
#!/bin/bash
gunicorn app:server
I specify that I have a shared volume named app
between the host and the container. So entrypoint.sh is accessible by the container.
The log of the container is displaying:container_api | ./entrypoint.sh: line 3: gunicorn: command not found
I also add the docker-compose file to see how the containers are built:
version: "3"
services:
worker:
build:
dockerfile: ./worker/Dockerfile
container_name: container_worker
environment:
- PYTHONUNBUFFERED=1
volumes:
- ./api:/app/
- ./worker:/app2/
api:
build:
dockerfile: ./api/Dockerfile
container_name: container_api
volumes:
- ./api:/app/
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "${API_PORT}:8050"
depends_on:
- worker
What is weird is that when I was using Flask as development server, I had no problem using the packages installed via requirement.txt in my Dash app. It seems that using a package outside the Dash app (in the entrypoint script) is making problem. Do you know why?
I hope I was clear in my explanations. Thank you for your help,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,看来我发现了为什么有这个问题。
我的开发机器是一台遥远的服务器,我通过远程SSH扩展程序的本地计算机上的VSCODE开发了它。我检查了路径,实际上它有一些奇怪的东西,里面有一些vscode元素。
因此,我尝试在没有VSCODE的情况下启动Docker,并且正在工作。我真的不知道如何解决此问题,但是我会在VSCODE帖子上找到答案。
非常感谢您的帮助
Ok it seems I discovered why I have this problem.
My development machine is a distant server and I'm developping on it via Vscode on my local machine with remote-ssh extension. I checked the Path and it's actually something weird with some vscode elements inside.
So I tried launching the docker without Vscode and it's working. I really don't know how to fix this issue but I will find out on vscode posts.
Thank you very much for your help