【发布时间】: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