see*_*ode 35 macos docker google-cloud-run
预期行为:我可以运行使用 Apple M1 芯片构建的容器。
\n观察到的行为:
\n假设您有 Google Cloud Run 帐户并且可以将 Docker 镜像推送到 Google Container Registry。我在这个例子中使用https://github.com/seenickcode/trivial-go-api。
\ncd trivial-go-apidocker build -t gcr.io/<YOUR GCR PROJECT ID>/example .docker push -t gcr.io/<YOUR GCR PROJECT ID>/exampleconsole.cloud.google.comGoogle Cloud Run > 创建新服务 > 选择推送的 Docker 映像(包含所有默认选项)> 运行Cloud Run error: Container failed to start. \nFailed to start and then listen on the port defined by the PORT environment variable. \nLogs for this revision might contain more information.\nRun Code Online (Sandbox Code Playgroud)\n日志:
\n2021-04-02 09:35:40.045 EDT\nCloud Run ReplaceService example hello@redactedforso.com {@type: type.googleapis.com/google.cloud.audit.AuditLog, authenticationInfo: {\xe2\x80\xa6}, authorizationInfo: [\xe2\x80\xa6], methodName: google.cloud.run.v1.Services.ReplaceService, request: {\xe2\x80\xa6}, requestMetadata: {\xe2\x80\xa6}, resourceLocation: {\xe2\x80\xa6}, resourceName: namespaces/myprojectforso-282419/services/example, response: {\xe2\x80\xa6}, servi\xe2\x80\xa6\nError\n2021-04-02 09:35:49.034 EDT\nterminated: Application failed to start: Failed to create init process: failed to load /app/main: exec format error\nWarning\n2021-04-02 09:35:49.174 EDT\nApplication exec likely failed\nNotice\n2021-04-02 09:57:43.102 EDT\nCloud Run ReplaceService example hello@redactedforso.com {@type: type.googleapis.com/google.cloud.audit.AuditLog, authenticationInfo: {\xe2\x80\xa6}, authorizationInfo: [\xe2\x80\xa6], methodName: google.cloud.run.v1.Services.ReplaceService, request: {\xe2\x80\xa6}, requestMetadata: {\xe2\x80\xa6}, resourceLocation: {\xe2\x80\xa6}, resourceName: namespaces/myprojectforso-282419/services/example, response: {\xe2\x80\xa6}, servi\xe2\x80\xa6\nError\n2021-04-02 09:57:50.657 EDT\nterminated: Application failed to start: Failed to create init process: failed to load /app/main: exec format error\nRun Code Online (Sandbox Code Playgroud)\n有关我正在构建图像的位置的系统详细信息:
\n重要笔记:
\nBep*_*e C 57
您正在构建 Google Cloud 不支持的 ARM 兼容映像。
我遇到了类似的问题,将我的 Mac M1 构建的映像推送到 Heroku,我使用buildx并设置了预期的平台解决了这个问题
docker buildx build --platform linux/amd64 -t myapp .
Run Code Online (Sandbox Code Playgroud)
我写了一篇Medium帖子来解释这个问题并提出2个解决方案。
Docker 在设计上是多平台的,可以在不同的架构上运行,但是,镜像必须与其运行的平台相匹配。这不是我们的情况。
N.B*_*ans 19
从 docker API version 1.40开始,您可以使用该选项指定需要构建映像的平台--platform,而无需使用 buildx。
docker build --platform=linux/amd64 -t myapp .
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27196 次 |
| 最近记录: |