The user-provided container failed to start and listen on the port defined provided by the PORT.

huangapple go评论124阅读模式
英文:

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

  1. version: '3.7'
  2. services:
  3. redis:
  4. image: redis
  5. restart: always
  6. htmlhost:
  7. container_name: stp-container
  8. image: stp-image
  9. build:
  10. dockerfile: docker/Dockerfile
  11. context: .
  12. restart: always
  13. env_file:
  14. - ./docker/.htmlhost.env
  15. ports:
  16. - "8080:8080"
  17. depends_on:
  18. - redis

我的Dockerfile

  1. FROM golang:1.18-alpine3.15 AS builder
  2. COPY ${PWD} /app-src
  3. WORKDIR /app-src
  4. RUN CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-static"' -o /app/htmlhost *.go
  5. COPY internal/server/http/web /app/internal/server/http/web
  6. FROM alpine:3.15
  7. LABEL MAINTAINER Kamaleshwar <bnkamalesh@gmail.com>
  8. # 以非根/非特权用户身份运行
  9. RUN adduser -D appuser
  10. USER appuser
  11. COPY --from=builder /app /home/appuser/app
  12. WORKDIR /home/appuser/app
  13. EXPOSE 8080
  14. CMD ["./htmlhost"]

我的htmlhost.env

  1. HTTP_PORT=8080
  2. 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

  1. version: '3.7'
  2. services:
  3. redis:
  4. image: redis
  5. restart: always
  6. htmlhost:
  7. container_name: stp-container
  8. image: stp-image
  9. build:
  10. dockerfile: docker/Dockerfile
  11. context: .
  12. restart: always
  13. env_file:
  14. - ./docker/.htmlhost.env
  15. ports:
  16. - "8080:8080"
  17. depends_on:
  18. - redis

My Dockerfile

  1. FROM golang:1.18-alpine3.15 AS builder
  2. COPY ${PWD} /app-src
  3. WORKDIR /app-src
  4. RUN CGO_ENABLED=0 go build -mod=vendor -ldflags '-s -w -extldflags "-static"' -o /app/htmlhost *.go
  5. COPY internal/server/http/web /app/internal/server/http/web
  6. FROM alpine:3.15
  7. LABEL MAINTAINER Kamaleshwar <bnkamalesh@gmail.com>
  8. # Run as a non-root/non-privileged user
  9. RUN adduser -D appuser
  10. USER appuser
  11. COPY --from=builder /app /home/appuser/app
  12. WORKDIR /home/appuser/app
  13. EXPOSE 8080
  14. CMD ["./htmlhost"]

My htmlhost.env

  1. HTTP_PORT=8080
  2. 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:

huangapple
  • 本文由 发表于 2023年6月29日 23:36:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76582579.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定