Skip to content

Registry Auth

The auth block configures authentication credentials for accessing private Docker registries. This is used within the container_registry resource to provide authentication details.

auth {
username = "myuser"
password = "mypassword"
}
auth {
hostname = "auth.company.com"
username = "service-account"
password = var.registry_password
}
FieldTypeRequiredDescription
usernamestringUsername for authentication
passwordstringPassword for authentication
hostnamestringHostname for authentication (can differ from registry hostname)
resource "container_registry" "private" {
hostname = "registry.example.com"
auth {
username = "developer"
password = "secretpassword"
}
}

Sometimes the authentication endpoint differs from the registry hostname:

resource "container_registry" "corporate" {
hostname = "images.corp.com"
auth {
hostname = "login.corp.com"
username = "service-bot"
password = var.auth_token
}
}
resource "container_registry" "secure" {
hostname = "secure-registry.com"
auth {
username = var.registry_username
password = var.registry_password
}
}