简体   繁体   English

Docker 容器在本地运行但在 Cloud Run 上失败

[英]Docker container runs locally but fails on Cloud Run

I moved project from PIP to Poetry and my Docker container failed to run on Google Cloud Run.我将项目从 PIP 移至 Poetry,而我的 Docker 容器无法在 Google Cloud Run 上运行。

Last string in Docker: Docker 中的最后一个字符串:

CMD ["poetry", "run", "uwsgi", "--http-socket", "0.0.0.0:80", "--wsgi-file", "/server/app/main.py", "--callable", "app", "-b 65535"]

It's works locally, it's works on other laptop, it's works in Cloud Run Emulator, but fails when I try to run it on Cloud Run.它在本地工作,在其他笔记本电脑上工作,在 Cloud Run Emulator 中工作,但是当我尝试在 Cloud Run 上运行它时失败。

Here is a Cloud Run log:这是 Cloud Run 日志:

Creating virtualenv my-project-xTUGyw3C-py3.8 in /home/.cache/pypoetry/virtualenvs

FileNotFoundError

[Errno 2] No such file or directory: b'/bin/uwsgi'

at /usr/local/lib/python3.8/os.py:601 in _execvpe
597│ path_list = map(fsencode, path_list)
598│ for dir in path_list:
599│ fullname = path.join(dir, file)
600│ try:
→ 601│ exec_func(fullname, *argrest)
602│ except (FileNotFoundError, NotADirectoryError) as e:
603│ last_exc = e
604│ except OSError as e:
605│ last_exc = e
Container called exit(1).

It's have correct port set.它有正确的端口设置。 It's doesn't use any environment variables.它不使用任何环境变量。 I don't use volumes, files passed to Docker through COPY.我不使用通过 COPY 传递给 Docker 的卷、文件。

Logs says that application can't find uwsgi file.日志显示应用程序找不到 uwsgi 文件。 That file doesn't exists in local version too, but it's works without any errors.该文件在本地版本中也不存在,但可以正常运行。

How that even possible that a docker container behaves differently? docker 容器的行为有何不同?

UPD: My Docker file UPD:我的 Docker 文件

FROM python:3.8
WORKDIR server
ENV PYTHONPATH $PYTHONPATH:/server
RUN pip install poetry==1.1.11
COPY poetry.lock /server
COPY pyproject.toml /server
RUN poetry install
EXPOSE 80
COPY /data /server/data
COPY /test /server/test
COPY /app /server/app
CMD ["poetry", "run", "uwsgi", "--http-socket", "0.0.0.0:80", "--wsgi-file", "/server/app/main.py", "--callable", "app", "-b 65535"]

adding HOME=/root to the CMD, fixed the problem for me.HOME=/root添加到 CMD,为我解决了问题。

CMD HOME=/root poetry run python main.py

Apparently home is not set correctly and this is a known issue显然 home 设置不正确,这是一个已知问题

暂无
暂无

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

相关问题 Docker 容器在本地运行但无法在 Cloud Run 上提供 dbt 文档 - Docker container runs locally but fails on Cloud Run to serve dbt docs Streamlit with Poetry 在 Docker 本地运行,但不在 Cloud Run 上运行 - Streamlit with Poetry running in Docker locally but not on Cloud Run 如何在 Cloud Run 中部署带卷的 docker 容器 - How to Deploy a docker container with volume in Cloud Run Cloud Run 中 Docker 容器上的 POST 出现 405 错误 - 405 error for POST on Docker Container in Cloud Run 使用 docker-compose 在本地运行胶水容器 - run glue container locally using docker-compose Cloud Run Docker 容器 - 如何访问 VM 上的数据库? - Cloud Run Docker container - How to access DB on VM? Docker 在云运行作业中运行抛出 ClassNotFoundException,在 Docker 桌面上运行良好 - Docker Running In Cloud Run Jobs Throws ClassNotFoundException, Runs Fine On Docker Desktop 在本地运行云运行应用程序时 GCSFuse 未找到默认凭据 docker - GCSFuse not finding default credentials when running a cloud run app docker locally 导入 numpy C 扩展无法在本地容器中运行(sam local invoke),而它在本地完美运行(python.\test.py) - Importing the numpy C-extensions failed to run in local container (sam local invoke) whereas it runs perfectly locally ( python .\test.py) GCP Cloud Run 容器失败并显示未捕获信号:11 分段错误 - 节点 - Fastify - GCP Cloud Run container fails with Uncaught signal: 11 Segmentation fault - Node - Fastify
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM