英文:
The user-provided container failed to start and listen on the port defined provided by the PORT
问题
我是新手使用Google Cloud平台,但我成功在Cloud Run上构建和部署了一个简单的页面。然后我尝试使用这个git 'https://github.com/bnkamalesh/htmlhost' 进行部署,但卡在了这个错误上:
> Revision 'stp-container-00001-wtr' 还没有准备好,无法提供流量。用户提供的容器启动失败,并且无法监听由环境变量PORT=8080定义的端口。
我在Cloud Shell上以“本地”方式运行它,它运行得很好,但一旦我在Cloud Run上构建并推送它到我的存储库,我就会遇到这个错误。我将端口定义为8000,尝试了8080,但仍然无法工作。
可以解释一下为什么我能够在本地使其工作,但在Cloud Run上却不行吗?
我的docker-compose.yml
version: '3.7'
services:
redis:
image: redis
restart: always
htmlhost:
container_name: stp-container
image: stp-image
build:
dockerfile: docker/Dockerfile
context: .
restart: always
env_file:
- ./docker/.htmlhost.env
ports:
- "8080:8080"
depends_on:
- redis
我的Dockerfile
FROM golang:1.18-alpine3.15 AS builder
COPY ${PWD} /app-src
WORKDIR /app-src
RUN CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-static"' -o /app/htmlhost *.go
COPY internal/server/http/web /app/internal/server/http/web
FROM alpine:3.15
LABEL MAINTAINER Kamaleshwar <bnkamalesh@gmail.com>
# 以非根/非特权用户身份运行
RUN adduser -D appuser
USER appuser
COPY --from=builder /app /home/appuser/app
WORKDIR /home/appuser/app
EXPOSE 8080
CMD ["./htmlhost"]
我的htmlhost.env
HTTP_PORT=8080
DATASTORE_HOST=redis
我不明白发生了什么。
英文:
I am new to Google Cloud platform but I succeed to build and deploy a simple page on Cloud run. Then I tried to do it with this git 'https://github.com/bnkamalesh/htmlhost' and I am stuck with this error :
> Revision 'stp-container-00001-wtr' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
I ran it "locally" on Cloud shell and it worked fine but once I build and push it to my repository with Cloud run, I'm getting the error. I defined the PORT as 8000, I tried with 8080 but still not working.
What would explain that I succeed to make it work locally but not with Cloud run.
My docker-compose.yml
version: '3.7'
services:
redis:
image: redis
restart: always
htmlhost:
container_name: stp-container
image: stp-image
build:
dockerfile: docker/Dockerfile
context: .
restart: always
env_file:
- ./docker/.htmlhost.env
ports:
- "8080:8080"
depends_on:
- redis
My Dockerfile
FROM golang:1.18-alpine3.15 AS builder
COPY ${PWD} /app-src
WORKDIR /app-src
RUN CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-static"' -o /app/htmlhost *.go
COPY internal/server/http/web /app/internal/server/http/web
FROM alpine:3.15
LABEL MAINTAINER Kamaleshwar <bnkamalesh@gmail.com>
# Run as a non-root/non-privileged user
RUN adduser -D appuser
USER appuser
COPY --from=builder /app /home/appuser/app
WORKDIR /home/appuser/app
EXPOSE 8080
CMD ["./htmlhost"]
My htmlhost.env
HTTP_PORT=8080
DATASTORE_HOST=redis
I don't understand what is going on
答案1
得分: 1
Publishing this as community wiki for other's sake.
将此发布为社区维基以供他人参考。
as mentioned by @Guillaume Blaquiere
如@Guillaume Blaquiere所提到的
> Docker compose does not work on Cloud Run. But you have now the sidecar feature that allows you to do the same! Cloud Run now supports sidecar deployments — monitoring agents, proxies and more
> Docker Compose在Cloud Run上不起作用。但现在您有支持此操作的Sidecar功能! Cloud Run现在支持Sidecar部署-监视代理、代理和更多
Other reference that might help:
其他可能有用的参考资料:
英文:
Publishing this as community wiki for other's sake.
as mentioned by @Guillaume Blaquiere
> Docker compose does not work on Cloud Run. But you have now the sidecar feature that allow you to do the same! Cloud Run now supports sidecar deployments — monitoring agents, proxies and more
Other reference that might help:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论