docker - 如何使用 Google Cloud 从 Container Registry 部署 VM 镜像

标签 docker google-cloud-platform google-compute-engine gcloud google-container-registry

我可以看到我的 VM 镜像在执行以下命令后在 Google Container Registry 中可用:

docker tag sutechnology/transcode eu.gcr.io/supereye/transcode

docker push eu.gcr.io/supereye/transcode

gcloud auth configure-docker docker push eu.gcr.io/supereye/transcode

虽然我可以看到图像,但在 Google Compute Engine 中创建新实例时,我无法使用此图像。在创建新的 VM 实例时,如何使用在 Container Registry 中看到的镜像?下面是我的完整配置:
machine_type = "zones/europe-west2-b/machineTypes/n1-standard-1"
disk_type = "zones/europe-west2-b/diskTypes/pd-standard"

config = {
    'name': name,
    'machineType': machine_type,

    # Specify the boot disk and the image to use as a source.
    'disks': [
        {
            'boot': True,
            'autoDelete': True,
            'initializeParams': {
                'sourceImage': source_disk_image,
            }
        }
    ],

    # Specify a network interface with NAT to access the public
    # internet.
    'networkInterfaces': [{
        'network': 'global/networks/default',
        'accessConfigs': [
            {'type': 'ONE_TO_ONE_NAT', 'name': 'External NAT'}
        ]
    }],

    # Allow the instance to access cloud storage and logging.
    'serviceAccounts': [{
        'email': 'default',
        'scopes': [
            'https://www.googleapis.com/auth/devstorage.read_write',
            'https://www.googleapis.com/auth/logging.write'
        ]
    }],

    # Metadata is readable from the instance and allows you to
    # pass configuration from deployment scripts to instances.
    'metadata': {
        'items': [{
            # Startup script is automatically executed by the
            # instance upon startup.
            'key': 'startup-script',
            'value': startup_script,
            'VIDEOPATH': videopath
        }]
    }
}

以及下面的实例创建功能:
compute.instances().insert(
        project=project,
        zone=zone,
        body=config).execute()

最佳答案

Google Container Registry (GCR),用于存储 docker 镜像,然后用于创建容器 不是 计算引擎机器。

对于 Compute Engine,请使用现有机器的公共(public)镜像或自定义镜像快照。

For Ref:- https://cloud.google.com/container-registry



希望这可以帮助

关于docker - 如何使用 Google Cloud 从 Container Registry 部署 VM 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61994256/

相关文章:

mysql - 如何使用带有测试数据的自定义 mysql docker 镜像进行本地开发

c# - 使用 AWS Systems Manager Parameter Store 构建 ASP.NET Core 2.2 Docker 镜像

javascript - 如何POST到外部IP?

google-cloud-platform - 无论如何,我可以将抢占式实例用于数据流作业吗?

python - 在虚拟机(Google Cloud Platform)中使用 Cron 定期运行 Python 脚本

docker - Gitlab Runner:在其他机器上找不到microdnf/yum命令

docker - couchbase docker端口8091有301重定向

python - 在数据流上运行自定义模板时出现错误 'Unable to parse file'

c# - 如何使用 REST API 为 Bucket 和 BigQuery 启用 "Export Billing"信息谷歌云

google-compute-engine - 如何配置 gce 来路由路径(Nginx 中的 rewrite-target)