# Docker push does not support url prefix

**URL:** <https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709>\
**Category:** General\
**Tags:** docker, insecure-registry\
**Created:** [September 16, 2023, 10:05am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709 "2023-09-16T10:05:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidshen84](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/davidshen84/32/3968_2.png) [@davidshen84](https://forums.docker.com/u/davidshen84)\
**Post date:** [September 16, 2023, 10:05am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/1 "2023-09-16T10:05:11Z")

</div>

Hi,

I want to create a private docker registry in my k8s environment. According to the [documentation](https://docs.docker.com/registry/configuration/#http) of the docker registry, it supports a _url prefix_.

However, according to the docker [API specification](https://docs.docker.com/registry/spec/api/), all URLs start with **/** , indicating they do not support a URL prefix.

I have a container registry instance with the prefix `/registry/`. I tag an image as `test.com/registry/hello-world:latest`. When I do `docker push`, my router log show the request is send to `/v2/registry/hello-world`.

Is there anything I can do to make the docker engine to recognise the URL prefix?

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [September 16, 2023, 2:56pm UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/2 "2023-09-16T14:56:34Z")

</div>

The registry indeed has support for a prefix, but neither `docker login` nor `docker push` support it.  
Though, I have no idea why it exists.

I know Container Registries that can manage multiple registries (like Artifactory), that require you put a reverse proxy in front that is mapping domain names to url paths before forwarded it to the registry.

Though, I have no idea why this would make sense with the registry.

---

<div class="post-metadata">

**Author:** ![davidshen84](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/davidshen84/32/3968_2.png) [@davidshen84](https://forums.docker.com/u/davidshen84)\
**Post date:** [September 17, 2023, 1:28am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/3 "2023-09-17T01:28:31Z")

</div>

Would `docker push` consider supporting a URL prefix in the future? I think it would be very nice. Not all companies can afford to create a separate domain for each of their container registries.

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [September 17, 2023, 8:50am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/4 "2023-09-17T08:50:29Z")

</div>

If you feel it is a bug, open an issue in the Github Repositories. Though, I am not sure if this would need to be opened in [GitHub - docker/cli: The Docker CLI](https://github.com/docker/cli) or [GitHub - moby/moby: Moby Project - a collaborative project for the container ecosystem to assemble container-based systems](https://github.com/moby/moby).

I would probably open the issue in moby, as it would require changes on the docker api, the backend and the cli.

Why would a company need to pay for individual subdomains for their domain(s)? Most companies I work with do not even expose their registries to the internet - usually they are only reachable within private corporate networks, where they have full control about domain names and certificates. Though, none of them uses the open source registry.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 17, 2023, 7:42pm UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/5 "2023-09-17T19:42:37Z")

</div>

The prefix is not for what you think. You could use a proxy server and forward the request to the registry

> <https://github.com/distribution/distribution/issues/29>
>
> The registry should not assume it's running at the root of the server.
> 
> eg: both… https://myregistry/v2/ and https://myregistry/something/v2/ should be possible.
> 
> The typical scenario when this is happening is a registry being run through a corporate portal that would "mount" the registry backend on a subpath.
> 
> This remark is valid as well for client code to be written.  
> 
> See docker/docker-registry#284 for historical reference. Supersedes docker/docker-registry#818.
> 
> This can be accomplished by adding a configuration section to the "http" configuration section:
> 
> \`\`\`
> HTTP struct {
> ...
> 
> // Prefix specifies a prefix to mount the API urls at for the registry instance. For example,
> // instead of responding to paths at "/v2/...", the registry instance will respond to paths at 
> // "\<prefix\>/v2/...".
> Prefix string
> }
> \`\`\`

You can’t include it in the name of the image tag.

> [@davidshen84](#):
>
> Not all companies can afford to create a separate domain for each of their container registries.

As @meyay pointed out, you don’t need a whole new domain. I agree that creating a subdomain should be possible, but even if it isn’t, you can change the port instead of the name of the image:

```auto
docker build . -t test.com:5000/hello-world:latest
docker push test.com:5000/hello-world:latest

```

Using a subdomain would be more user friendly, but using a port internally shouldn’t be a problem either unless company policy allows only port 443 to be open. My registry ran that way for years before I configured a proxy, but even I can configure a subdomain for free and I’m not a company 🙂

---

<div class="post-metadata">

**Author:** ![davidshen84](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/davidshen84/32/3968_2.png) [@davidshen84](https://forums.docker.com/u/davidshen84)\
**Post date:** [September 17, 2023, 11:09pm UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/6 "2023-09-17T23:09:31Z")

</div>

Can you show me how you configured your proxy and how you pushed images to that container register?

According to stevvooe’s bug:

> The registry should not assume it’s running at the root of the server.  
> eg: both [https://myregistry/v2/](https://myregistry/v2/) and [https://myregistry/something/v2/](https://myregistry/something/v2/) should be possible.

Does he mean both `docker push https://myregistry/hell-world` and `docker push https://myregistry/something/hell-world` should be possible or something else? I am quite confused.

My registry is deployed in k8s, and I have an Istio ingress gateway. Currently, I simply match a URL prefix and reroute requests to the registry pod. But since `docker push` ignores the prefix, that match rule is ineffective.

Thanks

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [September 18, 2023, 8:41am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/7 "2023-09-18T08:41:48Z")

</div>

> [@davidshen84](#):
>
> Can you show me how you configured your proxy and how you pushed images to that container register?

No, I don’t have that (I tried to find it yesterday) but it wouldn’t help you. As I tried to explain in my previous post it is not what you need if your propblem is using another domain or subdomain. I can still give you some idea at the end of this comment.

> [@davidshen84](#):
>
> Does he mean both `docker push https://myregistry/hell-world` and `docker push https://myregistry/something/hell-world` should be possible or something else? I am quite confused.

No. That post was about the final API call not the name of your image which can’t be changed. It is your domain name or IP address, optionally the por tnumber and the rest of it is the path of the repository in the registry. You can’t prefix it without changing the name of the image in the registry.

> [@davidshen84](#):
>
> My registry is deployed in k8s

You could still configure the ingress to handle one more subdomain, but let’s say it is really not possible. Don’t configure a registry prefix but use its already existing path to configure the ingress. For example while I was reading your message, I started to remember what I did in my proxy. I wanted to use the same domain for the webinterface of “Portus” docker registry (discontinued) and the registry itself. By default it required to use a different port for the registry. So I configured my proxy to forward all requests to the registry when the path started with “/v2”. Assuming you don’t have any other service that has a similar path, it should work. You should also check the logs (client and server) if it doesn’t work and find out what path is still not handled by the ingress. If you have other services started with “/v2”, you can try to write a more complex rule. I don’t use istio, but I guess a regex could also help:

[https://istio.io/latest/docs/reference/config/networking/virtual-service/#RegexRewrite](https://istio.io/latest/docs/reference/config/networking/virtual-service/#RegexRewrite)

---

<div class="post-metadata">

**Author:** ![davidshen84](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/davidshen84/32/3968_2.png) [@davidshen84](https://forums.docker.com/u/davidshen84)\
**Post date:** [September 18, 2023, 10:03am UTC](https://forums.docker.com/t/docker-push-does-not-support-url-prefix/137709/8 "2023-09-18T10:03:46Z")

</div>

Yeah, rerouting all `/v2` to the registry pod is what I am doing right now. Thanks!
