当我使用适用于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守护程序)
发布评论