Answers: <p>Docker registry credentials is seting up in <a href="https://www.terraform.io/docs/providers/docker/index.html#registry-credentials" rel="nofollow noreferrer">provider configuration</a>.</p>
  
  <pre><code>provider "docker" {
    registry_auth {
      address = "quay.io:8181"
      username = "someuser"
      password = "somepass"
    } 
  }
  </code></pre>
  
  <p>Also possible to set env variables DOCKER_REGISTRY_USER and DOCKER_REGISTRY_PASS</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-03-11T15:34:57.990Z
Answers: Do not hardcode credentials, use variables instead.
Answers: Kyslik
Answers: CC BY-SA 4.0
Answers: 2019-03-11T10:21:13.973Z
Answers: 2019-03-11T10:21:13.973Z
Answers: Vasiliy  Shakhunov
Body: <p>How would I provide docker hub credentials to a private image in the following example? </p>
  
  <pre><code>data "docker_registry_image" "ubuntu" {
    name = "ubuntu:latest"
  }
  
  resource "docker_image" "ubuntu" {
    name          = "${data.docker_registry_image.ubuntu.name}"
    pull_triggers = ["${data.docker_registry_image.ubuntu.sha256_digest}"]
  }
  </code></pre>
  
Tags: <terraform>
Title: Terraform: Provide credentials for docker hub registry
UserDisplayName: AyKarsi
ThreadText: # Terraform: Provide credentials for docker hub registry
  
  (Asked by: username_0 on 2019-03-10)
  
  How would I provide docker hub credentials to a private image in the following example?
  
  ```
  data "docker_registry_image" "ubuntu" {
    name = "ubuntu:latest"
  }
  
  resource "docker_image" "ubuntu" {
    name          = "${data.docker_registry_image.ubuntu.name}"
    pull_triggers = ["${data.docker_registry_image.ubuntu.sha256_digest}"]
  }
  
  ```
  
  **Tags:** terraform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-11. Score: 1 | Accepted answer
  
  Docker registry credentials is seting up in [provider configuration](https://www.terraform.io/docs/providers/docker/index.html#registry-credentials).
  
  ```
  provider "docker" {
    registry_auth {
      address = "quay.io:8181"
      username = "someuser"
      password = "somepass"
    } 
  }
  
  ```
  
  Also possible to set env variables DOCKER\_REGISTRY\_USER and DOCKER\_REGISTRY\_PASS
  
  > **Comments:**
  > **username_2**: Do not hardcode credentials, use variables instead.  
  
  ---
  
  