Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Unhelpful error message when docker_image and docker_container are on different docker providers #201

Closed
dubo-dubon-duponey opened this issue Oct 8, 2019 · 4 comments
Milestone

Comments

@dubo-dubon-duponey
Copy link
Contributor

Terraform Version

v0.12.9

Affected Resource(s)

docker_image & docker_container

Terraform Configuration Files

resource "docker_image" "ubuntu" {
  name = "ubuntu:bionic"
}

resource "docker_container" "ubuntu" {
  provider = docker.something
  name  = "foo"
  image = docker_image.ubuntu.latest
}

Make sure that:

  • you have docker running locally
  • you have another, different node running docker (provided by docker.something)

Expected Behavior

Some "helpful" error message, mentioning that the docker_image resource is not available on that docker instance.

Actual Behavior

Unhelpful error message that suggest you do not have access to the image or it does not exist.

Error: Unable to create container with image sha256:2ca708c1c9ccc509b070f226d6e4712604e0c48b55d7d8f5adc9be4a4d36029a:
Unable to pull image sha256:2ca708c1c9ccc509b070f226d6e4712604e0c48b55d7d8f5adc9be4a4d36029a: error pulling image sha256:2ca708c1c9ccc509b070f226d6e4712604e0c48b55d7d8f5adc9be4a4d36029a: 
Error response from daemon: pull access denied for sha256, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Steps to Reproduce

  1. terraform apply

Important Factoids

Docker providers are accessed over ssh.

References

Originally mentioned in #15 (comment)

@mavogel mavogel added this to the v2.5.0 milestone Oct 9, 2019
@mavogel
Copy link
Contributor

mavogel commented Oct 13, 2019

Some "helpful" error message, mentioning that the docker_image resource is not available on that docker instance.

Hmm, I'd rather expect that the image would be pulled if is not present on the machine where the daemon is running. I wonder why the daemon says you're not authorized when pulling from the public docker hub. What do you think @dubo-dubon-duponey ?

@dubo-dubon-duponey
Copy link
Contributor Author

I don't know.

The issue is that a container resource on docker.node B references an image resource attached to docker.node A:

resource "docker_image" "ubuntu" {
  provider = docker.NODE_A
  name = "ubuntu:bionic"
}

resource "docker_container" "ubuntu" {
  provider = docker.NODE_B
  name  = "foo"
  image = docker_image.ubuntu.latest
}

I'm not sure how this could be made smart...
It doesn't even make sense to begin with - and maybe that scenario should just not be allowed...

That being said, I'm still very new to terraform overall, and I don't really understand the internals here...

Sorry @mavogel - hope I would have a more helpful opinion on this.

@mavogel
Copy link
Contributor

mavogel commented Oct 13, 2019

It doesn't even make sense, to begin with - and maybe that scenario should just not be allowed...

Well, I don't know how to prevent this in an easy way. Semantic versioning of the config file probably. I'll ask for feedback from the core devs tho.

@mavogel mavogel modified the milestones: v2.5.0, v2.6.0 Oct 14, 2019
@mavogel
Copy link
Contributor

mavogel commented Oct 15, 2019

Currently, this semantic check is not supported. See hashicorp/terraform-plugin-sdk#61 for more details.

@mavogel mavogel closed this as completed Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants