ko icon indicating copy to clipboard operation
ko copied to clipboard

Unable to use --bare and ko.local at the same time

Open lucasoares opened this issue 2 years ago • 3 comments

Hello.

I want to be able to publish a local image with a predefined name.

I'm trying to use this command:

KO_DOCKER_REPO=ko.local/my-name ko publish -t 0.0.1 --bare <main-package>

But it doesn't works since it tries to connect to a us.gcr.io registry.

There is any way to build a local image with a custom naming?

Thanks.

lucasoares avatar Jun 13 '22 15:06 lucasoares

-L rather than KO_DOCKER_REPO=ko.local works but still doesn't give you what you want. I don't think there's currently a way to load images into your local Docker daemon without naming it something starting in ko.local.

A workaround:

❯ docker tag $(ko publish -L ./cmd/help) help:0.0.1
2022/06/17 11:16:53 Using base gcr.io/distroless/static:nonroot@sha256:66cd130e90992bebb68b8735a72f8ad154d0cd4a6f3a8b76f1e372467818d1b4 for
github.com/google/ko/cmd/help
2022/06/17 11:16:54 Building github.com/google/ko/cmd/help for linux/amd64
2022/06/17 11:16:55 Loading ko.local/help-cdb6b75575d1a4d6484f09d553f6ccbd:3a5a1d87e1af5b62e687d7f01821a765aacb8d3cc8cc7a934d5c436007344efb
2022/06/17 11:16:55 Loaded ko.local/help-cdb6b75575d1a4d6484f09d553f6ccbd:3a5a1d87e1af5b62e687d7f01821a765aacb8d3cc8cc7a934d5c436007344efb
2022/06/17 11:16:55 Adding tag latest
2022/06/17 11:16:55 Added tag latest

❯ docker image ls help:0.0.1
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
help         0.0.1     03ee9d0409af   52 years ago   36.4MB

benmoss avatar Jun 17 '22 15:06 benmoss

https://github.com/google/ko/blob/eaba2b8aeea060fb1a747ac72d0e7ac2c4ac2016/pkg/commands/resolver.go#L172-L174 😬

This isn't currently a flag, but we could certainly add it as one to control the ko.local domain: https://github.com/google/ko/blob/f5762bedf31a4c6852d75febe1f509b892cc122f/pkg/commands/options/publish.go#L37

You could also wire up a DaemonOption to accept a Namer to control the rest of the image name (including using --bare).

jonjohnsonjr avatar Jun 17 '22 17:06 jonjohnsonjr

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Keep fresh with the 'lifecycle/frozen' label.

github-actions[bot] avatar Sep 16 '22 01:09 github-actions[bot]