gpt4 book ai didi

部署到 Google Compute Engine 的 Docker 镜像不断重启

转载 作者:太空宇宙 更新时间:2023-11-03 15:33:17 24 4
gpt4 key购买 nike

我使用 Docker Compose 通过 Google Cloud Build 构建了一个图像。在我的 cloudbuild.yml文件我有以下步骤:

  1. 使用 docker compose 构建 docker 镜像
  2. 标记构建的图像
  3. 创建实例模板
  4. 创建实例组

现在这就是问题所在,每次构建新实例时,从镜像创建的容器都会不断重启,但从未真正启动。尽管如此,我可以构建图像并将其作为实例上的容器启动,独立于来自云构建的图像。

我设法从日志中找到了一些线索:

E1219 19:13:52 7f28dce6d700 api_server.cc:184 Metadata request unsuccessful: Server responded with 'Forbidden' (403): Transport endpoint is not connected

oauth2.cc:289 Getting auth token from metadata server docker

我还通过在实例中运行以下命令获得了一些线索:

docker -a -i start <container_id>

输出:Unrecognized input header: 99

cloudbuild.yml文件看起来像(我用 ... 替换了一些变量):

#cloudbuild.yaml
steps:
- name: 'docker/compose:1.22.0'
args: ['-f', 'docker/docker-compose.tb.prod.yml', 'up', '-d']
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'tb:latest', '...']
- name: 'gcr.io/cloud-builders/gcloud'
args: [
'beta', 'compute', '--project=...', 'instance-templates', 'create-with-container',
'tb-app-staging-${COMMIT_SHA}',
'--machine-type=n1-standard-2', '--network=...', '--network-tier=PREMIUM', '--metadata=google-logging-enabled=true',
'--maintenance-policy=MIGRATE', '--service-account=...',
'--scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append',
'--tags=http-server,https-server', '--image=cos-stable-69-10895-62-0', '--image-project=cos-cloud', '--boot-disk-size=20GB', '--boot-disk-type=pd-standard',
'--container-restart-policy=always', '--labels=container-vm=cos-stable-69-10895-62-0',
'--boot-disk-device-name=...',
'--container-image=...',
]
- name: 'gcr.io/cloud-builders/gcloud'
args: [
'beta', 'compute', '--project=...', 'instance-groups',
'managed', 'rolling-action', 'start-update',
'tb-app-staging',
'--version',
'template=...',
'--zone=europe-west1-b',
'--max-surge=20',
'--max-unavailable=9999'
]
images: ['...']
timeout: 1200s

最佳答案

我发现了这个问题,我会自己回答这个问题,以防其他人遇到同样的问题。

问题是在我的 docker-compose.yml我有 stdin_open 的配置和 tty设置为 true 但我的 cloudbuild.yml file 不接受它并且默默地失败(烦人!)。

要解决此问题,您需要使用标志 --container-stdin--container-ttycreate-with-container 上命令。

可以在谷歌文档中找到更多详细信息 https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers

关于部署到 Google Compute Engine 的 Docker 镜像不断重启,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53865837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com