更新时间:2023-01-19 13:13:08
问题在于您在任何地方使用 127.0.0.1
的想法.这是错误的.
The issue is your notion using 127.0.0.1
anywhere you want. This is wrong.
所以如果你的机器 IP 是 192.168.0.101.然后下面的作品
So if your machine IP is 192.168.0.101. Then below works
1- docker build -t 127.0.0.1:5000/eliza/console:0.0.1 .
2- docker run -d -p 5000:5000 --name registry registry:2
3- docker tag a3703d02a199 127.0.0.1:5000/eliza/console:0.0.1
4- docker push 127.0.0.1:5000/eliza/console:0.0.1
5- curl -X GET http://127.0.0.1:5000/v2/eliza/console/tags/list
因为 docker run 将注册表映射到 127.0.0.1:5000 和 192.168.0.101:5000.现在在你的机器上只有这个 127.0.0.1
可以工作.现在当你使用
Because docker run maps the registry to 127.0.0.1:5000 and 192.168.0.101:5000. Now on your machine only this 127.0.0.1
will work. Now when you use
3- minikube ssh
您进入 minikube 机器,但它没有在 127.0.0.1:5000 上运行的注册表.所以错误.使用机器机器IP无法访问该机器内部的注册表.
You get inside the minikube machine and that doesn't have a registry running on 127.0.0.1:5000. So the error. The registry is no reachable inside this machine using the machine machine IP.
我通常解决这个问题的方法是在本地和其他虚拟机内部使用主机名.
The way I usually solve this is issue is by using host name both locally and inside the other VMs.
所以在你的机器上创建一个条目 /etc/hosts
So on your machine create a entry in /etc/hosts
docker.local 127.0.0.1
并将您的命令更改为
1- docker build -t docker.local:5000/eliza/console:0.0.1 .
2- docker run -d -p 5000:5000 --name registry registry:2
3- docker tag a3703d02a199 docker.local:5000/eliza/console:0.0.1
4- docker push docker.local:5000/eliza/console:0.0.1
5- curl -X GET http://docker.local:5000/v2/eliza/console/tags/list
然后当你使用 minikube ssh
时,在 /etc/hosts
And then when you use minikube ssh
, make a entry for docker.local
in /etc/hosts
docker.local 192.168.0.101
然后 curl -X GET http://docker.local:5000/v2/eliza/console/tags/list
编辑-1
对于 TLS 问题,您需要停止 minikube 内的 docker 服务
For the TLS issue you need to Stop the docker service inside minikube
systemctl stop docker
然后编辑/etc/systemd/system/docker.service.d/10-machine.conf
并修改
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --tlsverify --tlscacert/etc/docker/ca.pem --tlscert/etc/docker/server.pem --tlskey/etc/docker/server-key.pem --label provider=virtualbox --insecure-registry 10.0.0.0/24
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=virtualbox --insecure-registry 10.0.0.0/24
到
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --tlsverify --tlscacert/etc/docker/ca.pem --tlscert/etc/docker/server.pem --tlskey/etc/docker/server-key.pem --label provider=virtualbox --insecure-registry 10.0.0.0/24 --insecure-registry docker.local:5000 --insecure-registry 192.168.1.4:5000
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=virtualbox --insecure-registry 10.0.0.0/24 --insecure-registry docker.local:5000 --insecure-registry 192.168.1.4:5000
然后重新加载守护进程并启动docker服务
Then reload daemon and start the docker service
systemctl daemon-reload
systemctl start docker
之后尝试拉
docker pull docker.local:5000/eliza/console:0.0.1
命令应该可以工作