-2

The pods i am working with are being managed by kubernetes. When I use the docker restart command to restart a pod, sometimes the pod gets a new id and sometimes the old one. When the pod gets a new id, its state first goes friom running ->error->crashloopbackoff. Can anyone please tell me why is this happening. Also how frequently does kubernetes does the health check

  • You shouldn't touch Kubernetes containers with the `docker` command. Probably Kubernetes thinks the container died and creates a new one. – svenwltr Aug 22 '16 at 13:54
  • When K8S creates a new pod after one dies it will use a random ID. Use `kubectl` to manage k8s not the docker command. – ajtrichards Aug 22 '16 at 18:51

1 Answers1

2

Kubernetes currently does not use the docker restart command for many reasons (e.g., preserving the logs of older containers). Kubelet, the daemon on the node, creates a new container if the existing container terminated. In any case, users should not perform container lifecycle operations (e.g., stop, restart) on kubernetes-managed containers directly using docker, as it could cause unexpected behaviors.

EDIT: If you want kubernetes to restart your container automatically, set RestartPolicy in your pod spec to "Always" or "OnFailure". For more details, see http://kubernetes.io/docs/user-guide/pod-states/

Yu-Ju Hong
  • 6,511
  • 1
  • 19
  • 24