Helm Set Docker Image Tag Dynamically
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The normal way to set a Docker image tag dynamically in Helm is to make the tag a chart value and override it at deploy time. That keeps the chart reusable while letting CI, release tooling, or an operator choose the exact image version for each deployment.
Define the Tag in values.yaml
Start by modeling the image as structured values rather than hardcoding the full image string in the template.
Then reference those values in the workload template.
This is the core pattern. Once the template is wired that way, the tag can be changed without editing the chart source.
Override the Tag from the CLI
The most common dynamic override is --set during helm upgrade --install.
In CI, TAG is often:
- a Git commit SHA
- a semantic version
- a build number
- an environment-specific promoted tag
That makes the chart static while the release artifact stays dynamic.
Prefer --set-string for Tags
Some tags look numeric or contain characters that Helm and YAML may interpret in surprising ways. To avoid type conversion problems, prefer --set-string for tags.
This is especially helpful when tags contain dots, leading zeros, or long commit-like values.
Environment-Specific Values Files
If the tag should vary by environment but not necessarily by each deploy command, use values files.
values-prod.yaml:
Deploy with:
This is still dynamic, just at the file level rather than the CLI flag level.
For pipelines, a common pattern is:
- base chart values in
values.yaml - environment defaults in
values-prod.yaml - final release tag injected through
--set-string
Use Commit SHAs or Immutable Tags
From an operational perspective, dynamic does not mean arbitrary. You should still prefer immutable image tags over mutable tags such as latest.
Good example:
That makes rollbacks and incident analysis much easier because the running image version is unambiguous.
Keep the Chart, Build, and Registry Aligned
Dynamic tagging only works if the image really exists in the registry before Helm tries to deploy it.
A typical CI order is:
- build image
- push image
- deploy chart with that exact tag
If the deployment step runs first, Kubernetes may accept the manifest but fail to pull the image later.
Avoid Hardcoding the Full Image String Repeatedly
Bad pattern:
If that string is embedded in multiple templates, every tag change becomes a chart edit. Keep repository and tag separate so the deployment tool can override only the changing part.
You can also centralize image rendering in a helper template if the chart is large, but do that only when reuse justifies the added indirection.
Debugging Deployed Values
If the wrong image tag is running, inspect the rendered manifest and the release values.
That tells you whether the problem is:
- the values override was wrong
- the template rendered incorrectly
- the cluster is running an old release
Debugging the rendered output is faster than guessing based on the chart source alone.
Common Pitfalls
- Hardcoding the image tag directly in templates.
- Using
latestand then losing traceability during rollbacks. - Forgetting that tags can be parsed oddly and not using
--set-string. - Deploying a tag before the image is pushed to the registry.
- Spreading image-tag logic across multiple templates instead of one consistent values model.
Summary
- Put the image tag in Helm values, not directly in template literals.
- Override the tag dynamically with
--set-stringor environment-specific values files. - Prefer immutable tags such as commit SHAs or release versions.
- Ensure the image is published before deploying the chart that references it.
- Debug dynamic tag issues by inspecting release values and rendered manifests.
Related reading
- Helm template arithmetic division
- helm templating with toYaml
- Helm upgrade doesn't pull new container
- Helm UPGRADE FAILED cannot patch ... with kind Job, by update field image
- hostPath as volume in kubernetes
- How are intermediate containers formed?
- Helm Variables inside ConfigMap File
- Heroku deploying Deep Learning model

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.