无法连接到正在运行的Docker容器(minikube docker守护程序) [英] Unable to connect to running docker containers (minikube docker daemon)

查看:466
本文介绍了无法连接到正在运行的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

http://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守护程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆