Kubernetes GCP Error response from daemon: No command specified: CreateContainerError

4/21/2020

I am trying to push my container up to GCP Kubernetes in my cluster. My pod runs locally but it doesn't want to run on GCP. It comes back with this error Error response from daemon: No command specified: CreateContainerError

It worked if I run it locally in docker but once I push it up to the container registry on gcp and apply the deployment yaml using kubectl apply -f in my namespace it never brings it up and just keeps saying gce-exporting-fsab83222-85sc4 0/1 CreateContainerError 0 5m6s

I can't get any logs out of it either: Error from server (BadRequest): container "gce" in pod "gce-exporting-fsab83222-85sc4" is waiting to start: CreateContainerError

Heres my files below:

Dockerfile:

FROM alpine:3.8

WORKDIR /build

COPY test.py /build
RUN chmod 755 /build/test.py

CMD ["python --version"]
CMD ["python", "test.py"]

Python Script:

#!/usr/bin/python3

import time 

def your_function():
    print("Hello, World")

while True:
    your_function()
    time.sleep(10) #make function to sleep for 10 seconds

yaml file:

apiVersion: apps/v1 
kind: Deployment
metadata:
  name: gce-exporting
  namespace: "monitoring"
spec:
  selector:
    matchLabels:
      app: gce
  template:
    metadata:
      labels:
        app: gce
    spec:
      containers:
      - name: gce
        image: us.gcr.io/lab-manager/lab/gce-exporting:latest

I have tried using CMD and Entrypoint at the end to make sure the pod is running but no luck.

This is the output of the describe pod

Events:
  Type     Reason     Age               From                                             Message
  ----     ------     ----              ----                                             -------
  Normal   Scheduled  60s               default-scheduler                                Successfully assigned monitoring/gce-exporting-fsab83222-85sc4 to gke-dev-lab-standard-8efad9b6-8m66
  Normal   Pulled     5s (x7 over 59s)  kubelet, gke-dev-lab-standard-8efad9b6-8m66  Container image "us.gcr.io/lab-manager/lab/gce-exporting:latest" already present on machine
  Warning  Failed     5s (x7 over 59s)  kubelet, gke-dev-lab-standard-8efad9b6-8m66  Error: Error response from daemon: No command specified
-- soniccool
docker
google-cloud-platform
google-kubernetes-engine
kubernetes

2 Answers

4/21/2020

You might need to update your Dockerfile with following:

FROM python

WORKDIR /build
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8
COPY test.py /build
RUN chmod 755 /build/test.py

CMD ["python", "test.py"]

Then build and push the docker image and recreate pod. Hope it helps!

-- hoque
Source: StackOverflow

4/22/2020

It was a malformed character in my Dockerfile and caused it to crash.

-- soniccool
Source: StackOverflow