<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>

CC BY-SA 4.0
2019-03-11T15:34:57.990Z
Do not hardcode credentials, use variables instead.
Kyslik
CC BY-SA 4.0
2019-03-11T10:21:13.973Z
2019-03-11T10:21:13.973Z
Vasiliy  Shakhunov
<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>

<terraform>
Terraform: Provide credentials for docker hub registry
AyKarsi
# 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.
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.  

---

