diff --git a/README.md b/README.md index 2fc5a22cc9..f14982c86a 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,12 @@ identified by `KO_DOCKER_REPO`. `ko` can also publish images to a local Docker daemon, if available, by setting `KO_DOCKER_REPO=ko.local`, or by passing the `--local` (`-L`) flag. +Locally-published images can be used as a base image for other `ko` images: + +```yaml +defaultBaseImage: ko.local/example/base/image +``` + `ko` can also publish images to a local [KinD](https://kind.sigs.k8s.io) cluster, if available, by setting `KO_DOCKER_REPO=kind.local`. diff --git a/pkg/commands/config.go b/pkg/commands/config.go index b2f08a4a6e..1448c95c85 100644 --- a/pkg/commands/config.go +++ b/pkg/commands/config.go @@ -30,10 +30,12 @@ import ( "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/daemon" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/types" "github.com/google/ko/pkg/build" "github.com/google/ko/pkg/commands/options" + "github.com/google/ko/pkg/publish" "github.com/spf13/viper" ) @@ -68,6 +70,12 @@ func getBaseImage(platform string, bo *options.BuildOptions) build.GetBase { if err != nil { return nil, fmt.Errorf("parsing base image (%q): %v", baseImage, err) } + + // For ko.local, look in the daemon. + if ref.Context().RegistryStr() == publish.LocalDomain { + return daemon.Image(ref) + } + userAgent := ua() if bo.UserAgent != "" { userAgent = bo.UserAgent