[英]manifest unknown: Failed to fetch \"latest\" from request \"/v2/$PROJECT_ID/$IMAGE:latest/manifests/latest\ "."
I have some python files inside of a VM that will run every week to scrape info from a website.我在虚拟机中有一些 python 个文件,每周运行一次以从网站上抓取信息。 This is automated through cloud scheduler and cloud function and it is confirmed that it works.
这是通过 cloud scheduler 和 cloud function 自动完成的,并确认它可以工作。 I wanted to use cloud build and cloud run to update the code inside of the VM each time I update the code inside of the Github. I read somewhere that in order to deploy a container image to a VM, the VM has to have a container-os, so I manually made a new VM matching that criteria through compute engine.
每次我更新 Github 内部的代码时,我想使用云构建和云运行来更新虚拟机内部的代码。我在某处读到,为了将容器映像部署到虚拟机,虚拟机必须有一个容器-os,所以我通过计算引擎手动创建了一个符合该条件的新 VM。 The container-os VM is already made.
container-os 虚拟机已经制作完成。 I just need to have the container image for it updated with the new container image built with the updated code from Github.
我只需要用来自 Github 的更新代码构建的新容器镜像更新容器镜像。
I'm trying to build a container image that I will later use to update the code inside of a virtual machine.我正在尝试构建一个容器映像,稍后我将使用它来更新虚拟机内部的代码。 Cloud run is triggered every time I push to a folder in my Github repository.
每次我推送到我的 Github 存储库中的文件夹时,都会触发云运行。
I checked Container Registry and the images are being created, but I keep getting this error when I check the virtual machine:我检查了 Container Registry 并且正在创建图像,但是当我检查虚拟机时我一直收到此错误:
"Error: Failed to start container: Error response from daemon:
{
"message":"manifest for gcr.io/$PROJECT_ID/$IMAGE:latest not found: manifest unknown: Failed to fetch \"latest\" from request \"/v2/$PROJECT_ID/$IMAGE:latest/manifests/latest\"."
}"
Why is the request being made for the latest tag when I wanted the tag with the commit hash and how can I fix it?为什么在我想要带有提交 hash 的标签时请求最新标签,我该如何解决?
This is the virtual machine log (sudo journalctl -u konlet-startup):这是虚拟机日志(sudo journalctl -u konlet-startup):
Started Containers on GCE Setup.
Starting Konlet container startup agent
Downloading credentials for default VM service account from metadata server
Updating IPtables firewall rules - allowing tcp traffic on all ports
Updating IPtables firewall rules - allowing udp traffic on all ports
Updating IPtables firewall rules - allowing icmp traffic on all ports
Launching user container $CONTAINER
Configured container 'preemptive-public-email-vm' will be started with name 'klt-$IMAGE-xqgm'.
Pulling image: 'gcr.io/$PROJECT_ID/$IMAGE'
Error: Failed to start container: Error response from daemon: {"message":"manifest for gcr.io/$PROJECT_ID/$IMAGE:latest not found: manifest unknown: Failed to fetch \"latest\" from request \"/v2/$PROJECT_ID/$IMAGE/manifests/latest\"."}
Saving welcome script to profile.d
Main process exited, code=exited, status=1/FAILURE
Failed with result 'exit-code'.
Consumed 96ms CPU time
This is the cloudbuild.yaml:这是 cloudbuild.yaml:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA', './folder_name']
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA']
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'run-public-email'
- '--image'
- 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA'
- '--region'
- 'us-central1'
images:
- 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA'
This is the dockerfile:这是 dockerfile:
FROM python:3.9.7-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "hello.py" ]
This is hello.py:这是你好.py:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello world"
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
You can update the GCE Container-os VM with the latest image by using Gcloud command in cloudbuild.yaml file.您可以使用 cloudbuild.yaml 文件中的Gcloud 命令使用最新映像更新 GCE Container-os VM。 This command is used to update Compute Engine VM instances running container images.
此命令用于更新运行容器映像的 Compute Engine 虚拟机实例。
You could encounter a vm restart whenever the image is updated to the GCE container-os VM.每当映像更新到 GCE container-os VM 时,您都可能会遇到 vm 重启。 When this happens, it will allocate a new ip to the VM, you can use a Static IP to avoid it, if required.
发生这种情况时,它将为 VM 分配一个新的 ip,如果需要,您可以使用 Static IP 来避免它。
Example Cloudbuild.yaml:示例 Cloudbuild.yaml:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA', './folder_name']
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA']
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'compute'
- 'instances'
- 'update-container'
- 'Instance Name'
- '--container-image'
- 'gcr.io/$PROJECT_ID/$IMAGE:$COMMIT_SHA'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.