【发布时间】:2021-05-13 00:01:21
【问题描述】:
为了与 Docker 集成,我将 terraform 设置如下:
所需的提供者:
docker = {
source = "kreuzwerker/docker"
version = "2.11.0"
}
该提供者的实例化:
provider "docker" {
}
最后我在 resource 中按如下方式使用它:
data "docker_registry_image" "myapp" {
name = some_image_url
}
当我运行terraform init 时,它似乎仍然指的是 HashiCorp 的“旧”terraform 提供程序:
Initializing modules...
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/random versions matching "3.0.1"...
- Finding hashicorp/null versions matching "~> 3.0.0"...
- Finding hashicorp/external versions matching "~> 2.0.0"...
- Finding kreuzwerker/docker versions matching "2.11.0"...
- Finding latest version of hashicorp/docker...
- Finding hashicorp/google versions matching "~> 3.56.0"...
- Finding hashicorp/azurerm versions matching "~> 2.46.1"...
- Installing hashicorp/null v3.0.0...
- Installed hashicorp/null v3.0.0 (signed by HashiCorp)
- Installing hashicorp/external v2.0.0...
- Installed hashicorp/external v2.0.0 (signed by HashiCorp)
- Installing kreuzwerker/docker v2.11.0...
- Installed kreuzwerker/docker v2.11.0 (self-signed, key ID 24E54F214569A8A5)
- Installing hashicorp/google v3.56.0...
- Installed hashicorp/google v3.56.0 (signed by HashiCorp)
- Installing hashicorp/azurerm v2.46.1...
- Installed hashicorp/azurerm v2.46.1 (signed by HashiCorp)
- Installing hashicorp/random v3.0.1...
- Installed hashicorp/random v3.0.1 (signed by HashiCorp)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider
hashicorp/docker: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/hashicorp/docker
If you have just upgraded directly from Terraform v0.12 to Terraform v0.14
then please upgrade to Terraform v0.13 first and follow the upgrade guide for
that release, which might help you address this problem.
Did you intend to use kreuzwerker/docker? If so, you must specify that source
address in each module which requires that provider. To see which modules are
currently depending on hashicorp/docker, run the following command:
terraform providers
当我运行terraform providers 时,我确实看到了由docker_registry_image 引起的参考:
...
├── provider[registry.terraform.io/hashicorp/docker]
...
注意事项:
- 所有其他供应商都使用最新版本。
- 我使用的是 terraform 0.14.6。
- 上面给出的资源是我正在使用的唯一的 docker 资源。
- 我已经尝试在提供者和资源上使用别名,但它不起作用。
我该如何解决这个问题?谢谢!
【问题讨论】:
-
我在 terraform 云中遇到了同样的问题。我认为是 docker 提供程序语法的问题。找到解决办法后我会在这里回复。
-
@AndreLeonRangel 我已经为我们的案例解决了这个问题!我已经发布了答案;希望它也适合你! ;)
-
我必须在 hashcorp 的社区中创建支持票和主题。检查详细信息。感谢您的回答。 discuss.hashicorp.com/t/…
标签: docker terraform terraform-provider-docker