我有一个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
当我创建部署时,我在pod中获得了以下信息:
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
来自下图:
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中注册吗?我只是想在本地进行测试,并将我的代码/repo传递给朋友进行测试
谢谢
6条答案
按热度按时间5w9g7ksd1#
You can point your docker client to the VM's docker daemon by running
Then you can build your image normally and create your kubernetes resources normally using kubectl. Make sure that you have
in your YAML or JSON specs.
Additionally, there is a flag to pass in insecure registries to the minikube VM. However, this must be specified the first time you create the machine.
You may also want to read this when using a private registry http://kubernetes.io/docs/user-guide/images/
qcuzuvrc2#
AFAIR minikube在VM中运行,因此它不会看到您在主机上本地构建的映像,但是......如https://github.com/kubernetes/minikube/blob/master/docs/reusing_the_docker_daemon.md中所述,您可以使用
eval $(minikube docker-env)
来实际利用在minikube上运行的docker守护进程,并且从此在minikubes docker上构建映像,因此希望它可用于minikubes k8s引擎,而无需从外部注册表中提取rt4zxlrg3#
To use an image without uploading it, you can follow these steps: It is important that you be in same shell since you are setting environment variables!
e5nszbig4#
I ran in a similar issue with minikube v1.9.2, Kubernetes v1.18.0, Docker 19.03.2 on Centos 8.1.1911. All in a single machine used for develop, I chosen for a local insecure docker registry.
The following steps were useful for me to share the local insecure docker registry with local kubernetes/minikube env and to allow kube nodes (and also minikube) to reach Internet:
systemctl disable firewalld
Otherwise during minikube startup it is prompted the following:
VM is unable to access k8s.gcr.io, you may need to configure a proxy or set --image-repository.*
I wasted several days on this.
docker0
interface name with IP172.17.0.1
. The local insecure registry will be exposed to minikube on this IP./etc/docker/daemon.json
:{"insecure-registries" : ["172.17.0.1:5000"]}
systemctl restart docker.service
minikube start --insecure-registry="172.17.0.1:5000"
(if already running or yet started, run
minikube delete
before to start)docker build -t mydemo/demo .
docker tag mydemo/demo 172.17.0.1:5000/myminikubedemo
docker push 172.17.0.1:5000/myminikubedemo
kubectl create deployment mydemo --image=172.17.0.1:5000/myminikubedemo --dry-run=client -o=yaml > deployment.yaml
kubectl apply -f deployment.yaml
9avjhtql5#
In my case, the minikube VM can not pull the images even though they are stored locally and the
imagePullPolicy
is set toNever
.My workaround solution is creating a local docker repository and pushing these images to that repository. Then, specify the image as follow:
localhost:5000/image/name
. Sources: https://minikube.sigs.k8s.io/docs/handbook/registry/#docker-on-macosa2mppw5e6#
Docker pull,在每个节点中手动提取所有映像,或运行DaemonSet提取所有映像