Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow oci_push to use plain HTTP for a specific host. #57

Closed
wants to merge 1 commit into from

Conversation

abayer
Copy link
Contributor

@abayer abayer commented Nov 14, 2023

Right now, we can only push to HTTPS, which is creating some problems for a project I'm working on where we'd really like to push to a local registry container. We can in theory add a self-signed cert to that registry container, but the hoops you have to jump through to make that work on Docker Desktop for Mac are considerable and definitely require manual intervention, so it'd be really, really nice if we could instead optionally push to a http host.

This adds a new attribute to oci_push, plain_http_host, which is a string value for a Docker registry host, including port if needed. This is an optional attribute, defaulting to the empty string. It'll be passed to the ocitool call as --plain-http-host="<value>", and onwards from there to ResolverWithHeaders and on to credhelper.RegistryHostsFromDockerConfig. If it's non-empty, the returned docker.RegistryHosts function will check if the host parameter matches plainHTTPHost, and if so, it'll change the Scheme for the host from https to `http.

Right now, we can only push to HTTPS, which is creating some problems for a project I'm working on where we'd really like to push to a local registry container. We can in theory add a self-signed cert to that registry container, but the hoops you have to jump through to make that work on Docker Desktop for Mac are considerable and definitely require manual intervention, so it'd be really, really nice if we could instead optionally push to a `http` host.

This adds a new attribute to `oci_push`, `plain_http_host`, which is a string value for a Docker registry host, including port if needed. This is an optional attribute, defaulting to the empty string. It'll be passed to the `ocitool` call as `--plain-http-host="<value>"`, and onwards from there to `ResolverWithHeaders` and on to `credhelper.RegistryHostsFromDockerConfig`. If it's non-empty, the returned `docker.RegistryHosts` function will check if the `host` parameter matches `plainHTTPHost`, and if so, it'll change the `Scheme` for the host from `https` to `http.

Signed-off-by: Andrew Bayer <[email protected]>
@abayer abayer force-pushed the abayer/allow-plainhttp branch from ab652aa to 42cf3e5 Compare November 14, 2023 19:55
@abayer
Copy link
Contributor Author

abayer commented Nov 15, 2023

Soooo this doesn't work in a bunch of ways, as it turns out. The next problem is that dockerRegPusher.Mount has a hardcoded https - I did manage to work around that by creating a new resolver in CopyContent to use for that Mount call with the original ref for the parent, rather than a relative one, but that's probably a bad idea in a few ways.

And even once that part "worked", I was still unable to actually push - I think that's because the parent image and its layers aren't in the registry I'm trying to push to. I think that oci_push doesn't actually work at all if the "parent" image (based on the org.opencontainers.image.base.name annotation on parent layers) isn't in the registry you're pushing to, regardless of http vs https etc. Maybe. In any case, I'm giving up on this. =)

@abayer abayer closed this Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant