Terraform 与 docker provider ,无法拉取图像

Ija*_*han 5 terraform

我的 terraform config.tf:

 provider "docker" {
   host = "tcp://my_dockerhost:2376/"
 }


resource "docker_container" "ubuntu" {
  name = "foo"
  image = "${docker_image.ubuntu.latest}"
}


resource "docker_image" "ubuntu" {
  name = "ubuntu:precise"
}
Run Code Online (Sandbox Code Playgroud)

申请时出错:

 docker_image.ubuntu: Creating...
 latest: "" => "<computed>"
 name:   "" => "ubuntu:precise"
 Error applying plan:

 1 error(s) occurred:

 docker_image.ubuntu: **Unable to read Docker image into resource: Unable to find or pull image ubuntu:precise**
Run Code Online (Sandbox Code Playgroud)

我从我的系统中删除了所有现有的本地图像,然后再次运行,然后docker images我注意到它确实提取了图像,但仍然无法成功使用 apply 命令并导致相同的错误。

Inn*_*gbo 2

使用了你的确切配置,对我来说是成功的。请参阅下面的输出:

docker_image.ubuntu: Refreshing state... (ID: sha256:5b117edd0b767986092e9f721ba23649...f53f1f41aff9dd1861c2d4feubuntu:precise)
docker_container.ubuntu: Refreshing state... (ID: 0482ec57dadff257a64815b10ac1d97863844a16852af7326046bb2ce3c8de0a)
aws_key_pair.mykey: Refreshing state... (ID: mykey)
aws_instance.example: Refreshing state... (ID: i-054b71ec0f9fe55bb)
docker_image.ubuntu: Creating...
  latest: "" => "<computed>"
  name:   "" => "ubuntu:precise"
docker_image.ubuntu: Creation complete (ID: sha256:5b117edd0b767986092e9f721ba23649...f53f1f41aff9dd1861c2d4feubuntu:precise)
docker_container.ubuntu: Creating...
  bridge:           "" => "<computed>"
  gateway:          "" => "<computed>"
  image:            "" => "sha256:5b117edd0b767986092e9f721ba2364951b0a271f53f1f41aff9dd1861c2d4fe"
  ip_address:       "" => "<computed>"
  ip_prefix_length: "" => "<computed>"
  log_driver:       "" => "json-file"
  must_run:         "" => "true"
  name:             "" => "foo"
  restart:          "" => "no"
docker_container.ubuntu: Creation complete (ID: a069e59359f19902d75642c584746c70098ed4f76f04d4570ae53f2383774649)

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path:
Run Code Online (Sandbox Code Playgroud)