Using non-k3d localhost:5000 registry #828
-
[Migrated from Issue] What did you docreated a localhost:5000 docker repo with
How was the cluster created?
What did you do afterwards?
What did you expect to happenI expected the pod to work because testreg.yaml fit the spec given in https://k3d.io/v4.4.8/usage/guides/registries/ Everything does work when the registry is created with Screenshots or terminal output
Which OS & Architecture
Which version of
|
Beta Was this translation helpful? Give feedback.
Replies: 13 comments
-
I am having the same issue even with the k3d created registry |
Beta Was this translation helpful? Give feedback.
-
@jim-mclean just FYI that I've had success using I haven't had luck with non-k3d registries per the original issue though. config.yaml registries:
create:
name: k3d-registry.k3d.localhost
host: "0.0.0.0"
hostPort: "5000"
# this also works after `k3d registry create registry.k3d.localhost --port 5000`
#use:
#- k3d-registry.k3d.localhost:5000
config:
|
mirrors:
"k3d-registry.k3d.localhost":
endpoint:
- http://k3d-registry.k3d.localhost:5000 I've noticed the in-config created registry will use the exact name defined while the CLI prepends |
Beta Was this translation helpful? Give feedback.
-
Hi @eaepstein , thanks for opening this issue!
Let me know if that helped 👍 |
Beta Was this translation helpful? Give feedback.
-
@jim-mclean , what's the issue you're facing? |
Beta Was this translation helpful? Give feedback.
-
Hi @iwilltry42 .. Looks close, but not working yet. $ docker ps cat testreg.yaml
I tried connecting container=registry to network=k3d-k3s-default. k3d containers and the registries were all connected there, but it did not work. k3d registry list did not show it. When k3d creates a registry it is connected to network=bridge, but connecting my registry to that did not work either. Is my registry definition above correct? Which docker docker network should my registry container connect to? Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
It should be mirrors:
"registry:5000":
endpoint:
- "http://registry:5000" The network has to be the one of the k3d cluster, so you did that correctly as you wrote it.
UPDATE: added port to mirror name to make it work |
Beta Was this translation helpful? Give feedback.
-
No luck here. All my steps are shown below with version 4.4.8. I upgraded to v5.0.1 but got exactly same results.
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Running with --image registry:5000/testimage:local and everything else the same as described most recently above. No success but a change in the error messages...
The failure message says
I've tried adding "registry:5000" to "insecure-registries" in /etc/docker/daemon.json and restarting k3d, but the request is still expecting an https response. |
Beta Was this translation helpful? Give feedback.
-
@eaepstein , sorry I just got to revisit this today and finally play it through (before I was mostly on my phone typing). # 1. Create registry
$ docker run -d --restart=always -p 5000:5000 --name registry registry:2
# ...
# 2. Import an image into that registry
$ docker pull alpine:latest
# ...
$ docker tag alpine:latest localhost:5000/alpine:local
# ...
$ docker push localhost:5000/alpine:local
# ...
# 3. Create registries.yaml file:
$ cat << EOF > /tmp/registries.yaml
mirrors:
"registry:5000":
endpoint:
- "http://registry:5000"
EOF
# 4. Create k3d cluster using this config
$ k3d cluster create mycluster --registry-config /tmp/registries.yaml
# ...
# 5. Connect registry container to cluster network
$ docker network connect k3d-mycluster registry
# ...
# 6. Run Pod using that image
$ kubectl run alpine --image registry:5000/alpine:local --command -- tail -f /dev/null
# ...
# 7. Check that it worked
$ kubectl describe pod alpine
# ...
(I hope I didn't forget anything there) |
Beta Was this translation helpful? Give feedback.
-
Yup, adding the port to the mirror identifier works for me too. |
Beta Was this translation helpful? Give feedback.
-
You're welcome :) |
Beta Was this translation helpful? Give feedback.
-
Even better: Create registries.yaml file: kubectl run alpine --image localhost:5000/alpine:local --command -- tail -f /dev/null Everywhere localhost, except endpoint and docker run registry, which are one-off configurations. |
Beta Was this translation helpful? Give feedback.
@eaepstein , sorry I just got to revisit this today and finally play it through (before I was mostly on my phone typing).
My fault that the last try didn't work. I actually forgot to put the port as part of the mirror identifier in the registries.yaml.
I fixed it in my previous comment: #763 (comment)
I just followed all your steps and it works like this: