【发布时间】:2020-09-20 05:56:36
【问题描述】:
我正在尝试将我在 App Engine、Flex 环境中使用的应用程序容器化。我可以使用 Cloud Build 创建 Docker 映像、存储在 Cloud Registry 中并启动 GKE pod。但是,在部署和暴露之后,我收到以下错误:
severity: "ERROR"
textPayload: "Traceback (most recent call last):
File "main.py", line 19, in <module>
app = worldgiftart.create_app(config)
File "/app/worldgiftart/_init_.py", line 40, in create_app
from .crud import crud
File "/app/worldgiftart/crud.py", line 15, in <module>
from worldgiftart import get_model, storage
File "/app/worldgiftart/storage.py", line 20, in <module>
from google.cloud import storage
File "/usr/local/lib/python3.8/site-packages/google/cloud/storage/_init_.py", line 38, in <module>
from google.cloud.storage.blob import Blob
File "/usr/local/lib/python3.8/site-packages/google/cloud/storage/blob.py", line 54, in <module>
from google.cloud.iam import Policy
ModuleNotFoundError: No module named 'google.cloud.iam'
这是我的 Dockerfile:
FROM python:3
WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt
# Open port 80 for serving the webpage
EXPOSE 80
# Run main.py when the container launches
CMD ["python", "main.py"]
这里是requirements.txt:
Flask==1.1.2
google-cloud-datastore==1.12.0
google-cloud-storage==1.28.1
gunicorn==20.0.4
oauth2client==4.1.3
Flask-SQLAlchemy==2.4.1
PyMySQL==0.9.3
Flask-PyMongo==2.3.0
PyMongo==3.10.1
six==1.14.0
有什么建议要检查或更改吗?
谢谢 - 乔
【问题讨论】:
-
你试过在docker本地运行吗?似乎python没有找到你的模块,尝试检查python路径,在本地运行容器可以帮助调试过程。
-
谢谢 - 我会试一试。我认为问题可能是我需要为 Cloud Datastore 设置一些身份验证 - 在部署到 App Engine 时会自动处理这些身份验证,但不会使用本地 docker。
标签: python docker build google-kubernetes-engine