【发布时间】:2020-01-31 13:40:50
【问题描述】:
使用gcloud builds submit --tag gcr.io/projectname/testserver 成功部署容器然后尝试运行gcloud run deploy --image gcr.io/projectname/testserver --platform managed 后,我看到此错误:
$ gcloud run deploy --image gcr.io/projectname/testserver --platform managed
Please specify a region:
// options removed
Service name (testserver):
Allow unauthenticated invocations to [testserver] (y/N)? y
Deploying container to Cloud Run service [testserver] in project [projectname] region [us-central1]
X Deploying new service... Cloud Run error:
Container failed to start. Failed to start
and then listen on the port defined by the
PORT environment variable. Logs for this r
evision might contain more information.
X Creating Revision... Cloud Run error: C
ontainer failed to start. Failed to start
and then listen on the port defined by t
he PORT environment variable. Logs for th
is revision might contain more informatio
n.
. Routing traffic...
✓ Setting IAM Policy...
Deployment failed
ERROR: (gcloud.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
我有一个非常简单的项目,全部在根文件夹中:
// Dockerfile
FROM node:12-slim
# Create app folder
WORKDIR /usr/src/app
# Install app deps. Copy the lock file
COPY package*.json ./
RUN npm install
COPY . ./
CMD ["node", "testServer.js"]
// testServer.js
const Koa = require("koa");
const koa = new Koa();
koa.get('/', async ctx => {
ctx.body = "Koa server running"
});
const port = process.env.PORT || 8080;
koa.listen(port);
有人知道这是什么原因吗?从昨天开始一直在尝试解决它,现在即使是这个最小的项目,它似乎也有问题。
【问题讨论】:
-
如果在容器启动时记录了任何错误怎么办?您能否收集所有工件并将它们放在临时 GitHub 存储库中并发布链接。也许某个善良的灵魂可能会尝试重建?
标签: google-cloud-platform google-cloud-run