无法连接到正在运行的Docker容器(minikube docker守护程序)

编程入门 行业动态 更新时间:2024-10-26 10:29:20
本文介绍了无法连接到正在运行的Docker容器(minikube docker守护程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我使用适用于Windows的Docker Desktop运行我的Docker容器时,我可以使用

When I run my docker container using Docker Desktop for Windows I am able to connect to it using

docker run -p 5051:5000 my_app 0.0.0.0:5051

但是当我打开另一个终端并执行此操作

However when I open another terminal and do this

minikube docker-env | Invoke-Expression

并使用与上述相同的运行命令来构建并运行相同的容器

and build and run the same container using the same run command as above

我无法连接到正在运行的实例.

I cannot connect to the running instance.

我应该使用Docker Desktop运行和测试容器,然后使用minikube仅存储图像(对于Kubernetes)吗?还是可以运行它们并通过minikube对其进行测试?

Should I be running and testing the containers using Docker Desktop, then using minikube to store the images only (for Kubernetes)? Or can you run them and test them as well through minikube?

推荐答案

这是因为第二次尝试时,容器不在主机上运行,​​而是在minikube VM上运行.您可以使用minikube VM IP访问它. 要获取minikube ip,可以运行minikube ip

That's because on your second attempt, the container is not running on the host but on the minikube VM. You'll be able to access it using the minikube VM IP. To get the minikube ip you can run minikube ip

为什么?

调用minikube docker-env会将主机上的所有docker env变量设置为与minikube环境匹配.这意味着当您随后运行容器时,它将与minikube VM上的docker守护程序一起运行.

Invoking minikube docker-env sets all the docker env variable on your host to match the minikube environment. This means that when you run a container after that, it is run with the docker daemon on the minikube VM.

更多推荐

无法连接到正在运行的Docker容器(minikube docker守护程序)

本文发布于:2023-10-18 12:10:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504193.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   容器   正在运行   程序   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!