问题
I'm trying to use minikube and kitematic for testing kubernetes on my local machine. However, kubernetes fail to pull image in my local repository (ImagePullBackOff).
I try to solve with this issue : Can not pull docker image from private repo when using Minikube
But I have no /etc/init.d/docker, I think it's because of kinematic ? (I am on OS X)
EDIT :
I installed https://github.com/docker/docker-registry, and
docker tag local-image-build localhost:5000/local-image-build
docker push localhost:5000/local-image-build
My kubernetes yaml contains :
spec:
containers:
- name: backend-nginx
image: localhost:5000/local-image-build:latest
imagePullPolicy: Always
But it's still not working... Logs :
Error syncing pod, skipping: failed to "StartContainer"
for "backend-nginx" with ErrImagePull: "Error while pulling image:
Get http://127.0.0.1:5000/v1/repositories/local-image-build/images:
dial tcp 127.0.0.1:5000: getsockopt: connection refused
EDIT 2 :
I don't know if I'm on the good path, but I find this :
http://kubernetes.io/docs/user-guide/images/
But I don't know what is my DOCKER_USER...
kubectl create secret docker-registry myregistrykey --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
EDIT 3
now I got on my pod :
Failed to pull image "local-image-build:latest": Error: image library/local-image-build not found
Error syncing pod, skipping: failed to "StartContainer" for "backend-nginx" with ErrImagePull: "Error: image library/local-image-build not found"
Help me I'm going crazy.
EDIT 4
Error syncing pod, skipping: failed to "StartContainer" for "backend-nginx" with ErrImagePull: "Error response from daemon: Get https://192.168.99.101:5000/v1/_ping: tls: oversized record received with length 20527"
I added :
EXTRA_ARGS='
--label provider=virtualbox
--insecure-registry=192.168.99.101:5000
to my docker config, but it's still don't work, the same message....
By the way, I changed my yaml :
spec:
containers:
- name: backend-nginx
image: 192.168.99.101:5000/local-image-build:latest
imagePullPolicy: Always
And I run my registry like that :
docker run -d -p 5000:5000 --restart=always --name myregistry registry:2
回答1:
Use the minikube docker registry instead of your local docker
https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/#create-a-docker-container-image
Set docker to point to minikube
eval $(minikube docker-env)
Push to minikube docker
docker build -t hello-node:v1 .
Set your deployment to not pull IfNotPresent
K8S default is set to "Always" Change to "IfNotPresent"
imagePullPolicy: IfNotPresent
Related Issue
回答2:
I think I solved by doing
minikube start --vm-driver="virtualbox" --insecure-registry="$REG_IP":80
instead of just
minikube start
$REG_IP is :
REG_IP=docker-machine ip registry
Source
回答3:
Adding --insecure-registry="$REG_IP":80 does not seem to work for me.
I have to use wlredeye's answer at Can not pull docker image from private repo when using Minikube to get it working:
For an http registry this steps works for me:
- minikube ssh
- edit /var/lib/boot2docker/profile and add to $EXTRA_ARGS
--insecure-registry 192.168.99.1(your local machine's IP):5000
- restart the docker daemon
sudo /etc/init.d/docker restart
- Verify you can access the docker registry
curl -s -S http://192.168.99.1/v2/_catalog
This is minikube version: v0.14.0
回答4:
First you need to start a local registry, seems you have done it.
docker run -d -p 5000:5000 --restart=always --name myregistry registry:2
You can check your minikube IP by ifconfig
There should be output (after minikube start using virtualbox as VMdriver) looks like:
vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00
inet addr:192.168.99.1 Bcast:192.168.99.255 Mask:255.255.255.0
inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:515 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:86256 (86.2 KB)
Using
minikube start --insecure-registry=192.168.99.1:5000
You can actually check whether you can pull your own images simply by (within minikube)
docker pull 192.168.99.1:5000/your_own_repo/your_own_images
Hope this might help.
来源:https://stackoverflow.com/questions/38979231/imagepullbackoff-local-repository-with-minikube