我有一个由Dockerfile创建的以下图像:
REPOSITORY TAG IMAGE ID CREATED SIZE ruby/lab latest f1903b1508cb 2 hours ago 729.6 MB
我有以下YAML文件:
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: ruby-deployment spec: replicas: 2 template: metadata: labels: app: ruby spec: containers: - name: ruby-app image: ruby/lab imagePullPolicy: IfNotPresent ports: - containerPort: 4567
创建部署时,我在窗格中获得以下信息:
ruby-deployment-3830038651-sa4ii 0/1 ImagePullBackOff 0 7m ruby-deployment-3830038651-u1tvc 0/1 ImagePullBackOff 0 7m
和Failed to pull image "ruby/lab:latest": Error: image ruby/lab not found下面的错误:
Failed to pull image "ruby/lab:latest": Error: image ruby/lab not found
8m 2m 6 {kubelet minikube} spec.containers{ruby} Normal Pulling pulling image "ruby/lab:latest" 8m 2m 6 {kubelet minikube} spec.containers{ruby} Warning Failed Failed to pull image "ruby/lab:latest": Error: image ruby/lab not found 8m 2m 6 {kubelet minikube} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "ruby" with ErrImagePull: "Error: image ruby/lab not found"
为此,在docker中真正有必要注册吗?我只想在本地进行测试并将我的代码/存储库传递给朋友以进行测试
谢谢
您可以通过运行将Docker客户端指向VM的docker守护程序
eval $(minikube docker-env)
然后,您可以正常使用kubectl构建映像并正常创建kubernetes资源。确保你有
imagePullPolicy: IfNotPresent
在您的YAML或JSON规范中。
此外,还有一个标志可以将不安全的注册表传递给minikube VM。但是,必须在初次创建计算机时指定它。
minikube start --insecure-registry
使用私有注册表http://kubernetes.io/docs/user- guide/images/时,您可能还需要阅读此内容。