Frequently Asked Questions
How can I set
Using -ldflags is a common way to embed version info in go binaries (In fact, we do this for
go build, it's not possible to use this flag directly; however, you can use the
GOFLAGS environment variable instead:
GOFLAGS="-ldflags=-X=main.version=1.2.3" ko build .
Currently, there is a limitation that does not allow to set multiple arguments in
-ldflags multiple times also does not work.
In this use case, it works best to use the
builds section in the
Why are my images all created in 1970?
In order to support reproducible builds,
ko doesn't embed timestamps in the images it produces by default.
ko does respect the
SOURCE_DATE_EPOCH environment variable, which will set the container image's timestamp accordingly.
KO_DATA_DATE_EPOCH environment variable can be used to set the modtime timestamp of the files in
For example, you can set the container image's timestamp to the current timestamp by executing:
export SOURCE_DATE_EPOCH=$(date +%s)
or set the timestamp of the files in
KO_DATA_PATH to the latest git commit's timestamp with:
export KO_DATA_DATE_EPOCH=$(git log -1 --format='%ct')
Can I build Windows containers?
Yes, but support for Windows containers is new, experimental, and tenuous. Be prepared to file bugs. 🐛
The default base image does not provide a Windows image.
You can try out building a Windows container image by setting the base image to a Windows base image and building with
For example, to build a Windows container image, update your
.ko.yaml to set the base image:
And build for
ko build ./ --platform=windows/amd64
Known issues 🐛
- Symlinks in
kodataare ignored when building Windows images; only regular files and directories will be included in the Windows image.
Can I optimize images for eStargz support?
Yes! Set the environment variable
GGCR_EXPERIMENT_ESTARGZ=1 to produce eStargz-optimized images.
ko support autocompletion?
ko completion generates a Bash/Zsh/Fish/PowerShell completion script.
You can get how to load it from help document.
ko completion [bash|zsh|fish|powershell] --help
Or, you can source it directly:
source <(ko completion)
ko work with Kustomize?
ko resolve -f - will read and process input from stdin, so you can have
ko easily process the output of the
kustomize build config | ko resolve -f -
ko integrate with other build and development tools?
Oh, you betcha. Here's a partial list:
kosupport in Carvel's
kosupport in Skaffold
koextension for Tilt
kosupport for goreleaser (proposed)
ko work with OpenShift Internal Registry?
Yes! Follow these steps:
- Connect to your OpenShift installation
- Expose the OpenShift Internal Registry so you can push to it:
- Export your token to
oc registry login --to=$HOME/.docker/config.json
- Create a namespace where you will push your images, i.e:
- Execute this command to set
KO_DOCKER_REPOto publish images to the internal registry.
export KO_DOCKER_REPO=$(oc registry info --public)/ko-images