I have a docker image which was created for training images for object detection.
Here is the dockerfile for my image.
FROM python:3
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY /src/ /Training
WORKDIR /Training
CMD ["/bin/bash"]
To create this container I used
sudo docker image build -t training .
The container of this image runs fine and I'm able to train on my computer.
I pushed this image to my private docker hub repository using
docker tag training abhishekkaranath/training:training
docker push abhishekkaranath/training:training
training image in my private docker hub repository
I created a secret for my deployment file using
kubectl create secret docker-registry hubsecret --docker-server=https://index.docker.io/v1/ --docker-username=my_username --docker-password=my_docker_hub_password --docker-email=my_email
Below is my deployment.yaml file
apiVersion: v1
kind: Pod
metadata:
name: podtest
spec:
containers:
- name: podtest
image: abhishekkaranath/training:training
imagePullSecrets:
- name: hubsecret
I created this pod from my terminal using
kubectl create -f deployment.yaml
This gave result:
pod/podtest created
While checking my minikube dashboard I get an error saying "Back-off restarting failed container".
Back off restarting failed container
I have tried pulling hello world images from my private docker hub repository into kubernetes which works fine and the pods are up and running. So that means there is no problem in pulling the images from the private docker hub repository.
kubectl get pods
NAME READY STATUS RESTARTS AGE
podtest 0/1 CrashLoopBackOff 8 20m
kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 11d v1.14.2
kubectl describe pods podtest
Name: podtest
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: minikube/10.0.2.15
Start Time: Thu, 06 Jun 2019 18:33:02 +0400
Labels: <none>
Annotations: <none>
Status: Running
IP: 172.17.0.9
Containers:
podtest:
Container ID: docker://14b9fcc51c8b4a594e0b38580444e2fedd61a636f4e57374d788c9ba5bf9fbcf
Image: abhishekkaranath/training:training
Image ID: docker-pullable://abhishekkaranath/training@sha256:619468dd0b74b30babfd7c0702c21ea71e9fb70ba3971ec26e8279fdbd071ec7
Port: <none>
Host Port: <none>
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Thu, 06 Jun 2019 18:54:19 +0400
Finished: Thu, 06 Jun 2019 18:54:19 +0400
Ready: False
Restart Count: 9
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-lb9js (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-lb9js:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-lb9js
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 25m default-scheduler Successfully assigned default/podtest to minikube
Normal Pulled 23m (x5 over 25m) kubelet, minikube Container image "abhishekkaranath/training:training" already present on machine
Normal Created 23m (x5 over 25m) kubelet, minikube Created container podtest
Normal Started 23m (x5 over 25m) kubelet, minikube Started container podtest
Warning BackOff 4m51s (x94 over 24m) kubelet, minikube Back-off restarting failed container
kubectl --v=8 logs podtest
I0606 19:03:24.821394 3978 loader.go:359] Config loaded from file /home/abhishekkaranath/.kube/config
I0606 19:03:24.826732 3978 round_trippers.go:416] GET https://192.168.99.100:8443/api/v1/namespaces/default/pods/podtest
I0606 19:03:24.826748 3978 round_trippers.go:423] Request Headers:
I0606 19:03:24.826757 3978 round_trippers.go:426] Accept: application/json, */*
I0606 19:03:24.826764 3978 round_trippers.go:426] User-Agent: kubectl/v1.14.1 (linux/amd64) kubernetes/b739410
I0606 19:03:24.835800 3978 round_trippers.go:441] Response Status: 200 OK in 9 milliseconds
I0606 19:03:24.835818 3978 round_trippers.go:444] Response Headers:
I0606 19:03:24.835827 3978 round_trippers.go:447] Content-Length: 2693
I0606 19:03:24.835834 3978 round_trippers.go:447] Date: Thu, 06 Jun 2019 15:03:24 GMT
I0606 19:03:24.835840 3978 round_trippers.go:447] Content-Type: application/json
I0606 19:03:24.835870 3978 request.go:942] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"podtest","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/podtest","uid":"fd87b14c-8867-11e9-a507-0800276a11ac","resourceVersion":"415630","creationTimestamp":"2019-06-06T14:33:02Z"},"spec":{"volumes":[{"name":"default-token-lb9js","secret":{"secretName":"default-token-lb9js","defaultMode":420}}],"containers":[{"name":"podtest","image":"abhishekkaranath/training:training","resources":{},"volumeMounts":[{"name":"default-token-lb9js","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount"}],"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","serviceAccountName":"default","serviceAccount":"default","nodeName":"minikube","securityContext":{},"imagePullSecrets":[{"name":"hubsecret"}],"schedulerName":"default-scheduler","tolerations":[{"key":"node.kubernetes.io/not-ready","oper [truncated 1669 chars]
I0606 19:03:24.840211 3978 round_trippers.go:416] GET https://192.168.99.100:8443/api/v1/namespaces/default/pods/podtest/log
I0606 19:03:24.840227 3978 round_trippers.go:423] Request Headers:
I0606 19:03:24.840235 3978 round_trippers.go:426] Accept: application/json, */*
I0606 19:03:24.840241 3978 round_trippers.go:426] User-Agent: kubectl/v1.14.1 (linux/amd64) kubernetes/b739410
I0606 19:03:24.843633 3978 round_trippers.go:441] Response Status: 200 OK in 3 milliseconds
I0606 19:03:24.843657 3978 round_trippers.go:444] Response Headers:
I0606 19:03:24.843666 3978 round_trippers.go:447] Date: Thu, 06 Jun 2019 15:03:24 GMT
I0606 19:03:24.843673 3978 round_trippers.go:447] Content-Type: text/plain
kubectl get events
LAST SEEN TYPE REASON OBJECT MESSAGE
37m Warning BackOff pod/dhubservice Back-off restarting failed container
31m Normal Scheduled pod/podtest Successfully assigned default/podtest to minikube
29m Normal Pulled pod/podtest Container image "abhishekkaranath/training:training" already present on machine
29m Normal Created pod/podtest Created container podtest
29m Normal Started pod/podtest Started container podtest
69s Warning BackOff pod/podtest Back-off restarting failed container
docker pull abhishekkaranath/training:training
training: Pulling from abhishekkaranath/training
Digest: sha256:619468dd0b74b30babfd7c0702c21ea71e9fb70ba3971ec26e8279fdbd071ec7
Status: Image is up to date for abhishekkaranath/training:training
Looking into:
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Completed
Exit Code: 0
Started: Thu, 06 Jun 2019 18:54:19 +0400
Finished: Thu, 06 Jun 2019 18:54:19 +0400
Ready: False
Restart Count: 9
Your pod was scheduled, container was created and finished his job. As per documentation Pod Lifecycle.