在 Minikube 中运行本地 docker 镜像

Sha*_*eKm 4 docker minikube

我已经为 Windows 和 minikube 设置了 Docker。此处列出的 (k8s.gcr.io/echoserver:1.10) 示例工作正常:https ://kubernetes.io/docs/setup/learning-environment/minikube/ 。

但是,当我在 c:\dev\helloworld 下创建简单的 .NET MVC 应用程序并尝试在 Minikube 中运行时,我得到状态:CrashLoopBackOff

环境:Windows 10 企业版

请帮忙。我需要设置什么才能完成这项工作? 你

Ami*_*pta 11

如果您在运行时将运行在 minikube VM 中的 Docker 守护程序作为目标,docker build而不是运行在主机上的 Docker for Windows 守护程序,那么 minikube Docker 将有权访问该映像,并且后续kubectl run命令将按需要运行。我不确定在 Windows 上运行哪些命令,但在 Mac 或 Linux 等 POSIX 系统上,您可以运行:

# make 'docker' commands use daemon in minikube
eval $(minikube docker-env)

# build image so that minikube Docker daemon has it
docker build -t hello-world:v1 .

# deploy to kubernetes
kubectl run hello-world --image=hello-world:v1 --port=8080

# unset DOCKER environment variables so it goes back to 
# targetting the usual Docker for Windows
eval $(minikube docker-env -u)
Run Code Online (Sandbox Code Playgroud)

我不知道eval在 Windows 上运行是否正确,但如果你只是运行minikube docker-env它,它可能会给你一些说明,例如对我来说它给出:

$ minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.103:2376"
export DOCKER_CERT_PATH="/Users/amitgupta/.minikube/certs"
# Run this command to configure your shell:
# eval $(minikube docker-env)
Run Code Online (Sandbox Code Playgroud)

  • 是的。那行得通。在 Windows Power Shell 中,您可以执行以下操作:PS C:\minikube> minikube docker-env。之后,您应该会在 minikube 中看到镜像列表,包括新构建的 docker 镜像。另外,在部署文件中: imagePullPolicy: Never (3认同)