My pod is always in 'ContainerCreating' state

10/7/2021

When I ssh into minikube and pull the image from docker hub it pulls the image successfully:

$ docker pull mysql:5.7

So I understand network is not an issue.

But when I try deploying using the following command it goes into 'ContainerCreating' endlessly.

$ kubectl apply -f my-depl.yaml

#my-depl.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-depl
  labels:
    app: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
        - name: mysql
          image: mysql:5.7
          imagePullPolicy: IfNotPresent 
          ports:
            - containerPort: 3306
          volumeMounts:
            - mountPath: "/var/lib/mysql"
              subPath: "mysql"
              name: mysql-data
          env:
            - name: MYSQL_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mysql-root-password
                  key: ROOT_PASSWORD
      volumes:
        - name: mysql-data
          persistentVolumeClaim:
            claimName: mysql-data-disk

Please let me know if there is anything wrong with the above yaml file or any other helpful debug tips that can help pull the image successfully from the Docker Hub.

-- srigu
kubernetes
minikube

1 Answer

10/8/2021

I do not know the reason but my container got created automatically without any problems when I restarted the Minikube. It would help if someone can add the reason behind this behavior.

-- srigu
Source: StackOverflow