gpt4 book ai didi

docker - 在terraform中使用注册表中的docker镜像

转载 作者:行者123 更新时间:2023-12-02 19:44:54 25 4
gpt4 key购买 nike

我正在尝试使用以Terraform托管在Docker Hub注册表中的Docker镜像。当我运行terraform apply时说它不存在或需要docker登录。然后失败,并拒绝对资源的请求访问。我究竟做错了什么?
main.tf:

provider "docker" {
host = "npipe:////.//pipe//docker_engine"

registry_auth {
address = "registry.hub.docker.com"
username = "username"
password = "passwword"
}
}

resource "docker_image" "ubuntu" {
name = "data.docker_registry_image.ubuntu.name"
pull_triggers = ["data.docker_registry_image.ubuntu.sha256_digest"]
}

data "docker_registry_image" "ubuntu" {
name = "ubuntu:latest"
}

版本.tf:
terraform {
required_providers {
docker = {
source = "terraform-providers/docker"
}
}
required_version = ">= 0.13"
}

错误输出:
Error: Unable to read Docker image into resource: Unable to pull image data.docker_registry_image.ubuntu.name: error pulling image data.docker_registry_image.ubuntu.name: Error response from daemon: pull access denied for data.docker_registry_image.ubuntu.name, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

on main.tf line 11, in resource "docker_image" "ubuntu":
11: resource "docker_image" "ubuntu" {

最佳答案

您需要从resource "docker_image" "ubuntu"块中删除四个引号。

关于docker - 在terraform中使用注册表中的docker镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64046769/

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