Skip to content

Container Registry

The container_registry resource configures additional Docker registries for use with image caching and container management. This allows you to authenticate against private registries and configure custom registry endpoints.

resource "container_registry" "private" {
hostname = "my-registry.company.com"
auth {
username = "myuser"
password = "mypassword"
}
}
resource "container_registry" "private" {
hostname = "my-registry.company.com"
auth {
hostname = "auth.company.com"
username = "service-account"
password = var.registry_password
}
}
FieldTypeRequiredDescription
hostnamestringHostname of the registry
authblockAuthentication configuration for the registry
FieldTypeDescription
meta.idstringFull resource identifier
meta.typestringResource type (always "container_registry")
meta.namestringResource name

Authentication configuration for the registry.

FieldTypeRequiredDescription
usernamestringUsername for authentication
passwordstringPassword for authentication
hostnamestringHostname for authentication (can differ from registry hostname)
resource "container_registry" "dockerhub" {
hostname = "registry.hub.docker.com"
auth {
username = "mydockerhubuser"
password = var.dockerhub_password
}
}
resource "container_registry" "corporate" {
hostname = "registry.corp.example.com"
auth {
hostname = "auth.corp.example.com"
username = "service-bot"
password = var.corporate_registry_token
}
}