可以使用以下命令在Kubernetes集群中运行 dnsutils 镜像,并要求在本地不存在时自动拉取:
kubectl run dnsutils --image-pull-policy=IfNotPresent --restart=Never -it --rm=true --image=tutum/dnsutils -- nslookup git.k3s
上述命令执行以下操作:
--image-pull-policy=IfNotPresent:指示Kubernetes在本地不存在镜像时才尝试从远程Registry中拉取镜像。--restart=Never:表示容器不应该重启。-it:表示创建交互式终端。--rm=true:当终止该容器时,删除该容器。--image=tutum/dnsutils:指定要运行的镜像名称。-- nslookup git.k3s:表示在容器中要运行的命令。
请注意,如果您的环境需要身份验证,则需要向Docker登录并将凭据添加到Kubernetes Secret中。另外,请确保您已经将 Docker Hub 或其他Registry 的配置添加到 Kubernetes 集群节点上。




