Skip to content

Image Cache

The image_cache resource creates a container registry cache for Docker images. It allows you to configure custom registries and network connections for caching Docker images locally.

resource "image_cache" "main" {
network {
id = resource.network.main.meta.id
}
}
resource "image_cache" "main" {
registry {
hostname = "private.registry.com"
auth {
username = "myuser"
password = "mypassword"
}
}
network {
id = resource.network.main.meta.id
ip_address = "10.0.1.100"
aliases = ["cache.local"]
}
}
FieldTypeRequiredDescription
registry[]blockCustom registries to configure for the cache
network[]blockNetworks to attach the cache container to
FieldTypeDescription
meta.idstringFull resource identifier
meta.typestringResource type (always "image_cache")
meta.namestringResource name

Configure additional registries for the image cache.

FieldTypeRequiredDescription
hostnamestringHostname of the registry
authblockAuthentication configuration for the registry

Authentication configuration for a registry.

FieldTypeRequiredDescription
hostnamestringHostname for authentication (can differ from registry hostname)
usernamestringUsername for authentication
passwordstringPassword for authentication

Network attachment configuration for the cache container.

FieldTypeRequiredDescription
idstringNetwork resource ID to attach to
ip_addressstringStatic IP address to assign
aliases[]stringNetwork aliases for the container
resource "image_cache" "main" {
network {
id = resource.network.lab.meta.id
}
}
resource "image_cache" "private" {
registry {
hostname = "my-registry.company.com"
auth {
username = "service-account"
password = var.registry_password
}
}
network {
id = resource.network.main.meta.id
ip_address = "192.168.1.50"
aliases = ["registry-cache.local"]
}
}