【问题标题】:Kubernetes GCP Error response from daemon: No command specified: CreateContainerError来自守护程序的 Kubernetes GCP 错误响应:未指定命令:CreateContainerError
【发布时间】:2020-04-21 18:47:17
【问题描述】:

我正在尝试将我的容器推送到集群中的 GCP Kubernetes。我的 pod 在本地运行,但它不想在 GCP 上运行。它返回此错误Error response from daemon: No command specified: CreateContainerError

如果我在 docker 本地运行它,它会起作用,但是一旦我将它推送到 gcp 上的容器注册表并在我的命名空间中使用 kubectl apply -f 应用部署 yaml,它就永远不会启动它,只是一直说 gce-exporting-fsab83222-85sc4 0/1 CreateContainerError 0 5m6s

我也无法从中获取任何日志: Error from server (BadRequest): container "gce" in pod "gce-exporting-fsab83222-85sc4" is waiting to start: CreateContainerError

以下是我的文件:

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 脚本:

#!/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 文件:

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

我已经尝试在最后使用 CMD 和入口点来确保 pod 正在运行,但没有运气。

这是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

【问题讨论】:

  • 您能否运行kubectl describe pods <podname> -n monitoring 并检查那里是否显示任何其他错误?
  • 添加到原始 desc @hoque
  • CMD ["python --version"] CMD ["python", "test.py"] 可以用ENTRYPOINT ["python"] CMD ["test.py"] 替换这两行并检查吗?
  • 如果没有在 Dockerfile 中安装 python,也可以使用FROM python:3 镜像。
  • @soniccool 用户 hoque 提供的解决方案是否解决了您的问题?

标签: docker kubernetes google-cloud-platform google-kubernetes-engine


【解决方案1】:

这是我的 Dockerfile 中的一个格式错误的字符,导致它崩溃。

【讨论】:

    【解决方案2】:

    您可能需要使用以下内容更新 Dockerfile:

    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"]
    

    然后构建并推送 docker 镜像并重新创建 pod。希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-06
      • 2016-05-24
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多