简体   繁体   English

如何保持 docker pod 没有在 K8S 中运行入口点?

[英]How to keep docker pod without entrypoint running in K8S?

I have the following dockerfile:我有以下 dockerfile:

FROM node:8 as build
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app

publish to our artifactory.发布到我们的工件。 However, as there is no command / entrypoint provided, the docker would simply end immediately.然而,由于没有提供命令/入口点,docker 将立即结束。 so I usually use docker run -d -t to run it.所以我通常使用docker run -d -t来运行它。 However, when deploying it in kubernetes, I cannot specify the args -d and -t since I will get an error that node does not know the arguments -d and -t.但是,在 kubernetes 中部署它时,我无法指定args -d 和 -t,因为我会收到一个错误,即节点不知道 arguments -d 和 -t。

When adding the following entrypoint,添加以下入口点时,

ENTRYPOINT [ "tail", "-f", "/dev/null"]

The machine keeps crashing机器一直在崩溃

How can I keep the pod running in background?如何让 pod 在后台运行?

Make use of -i and --tty option of kubectl run command. 利用kubectl run命令的-i--tty选项。

kubectl run -i --tty --image=<image> <name> --port=80 --env="DOMAIN=cluster"

More info here . 更多信息在这里

Update: 更新:

In case of yaml files make use of stdin and tty option. 如果是yaml文件,请使用stdintty选项。

apiVersion: v1 
kind: Pod 
metadata: 
  name: testpod
spec: 
  containers: 
    - name: testpod
      image: testimage
      stdin: true
      tty: true

More info here . 更多信息在这里

I got the same case.我遇到了同样的情况。 Besides除了

      stdin: true
      tty: true

I also need to add:我还需要补充:

      command:
        - /bin/bash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改 k8s Pod 的入口点,但保留 CMD - Change entrypoint of a k8s Pod, but keep the CMD 使用没有 minikube 的 docker 文件的 k8s 集群中的部署问题,但我的 pod 没有运行 - Deployment issue in k8s cluster using docker file without minikube, but my is pod not running 如何更新 k8s pod / Docker 容器的 /etc/services - How to update /etc/services for k8s pod / Docker container 是否可以像执行到 docker 容器或在 pod 内运行的容器一样执行到 K8s pod? - Is it possible to exec in to a K8s pod the same way we exec in to a docker containers or containers running inside of a pod? 在没有“特权”的情况下在 K8s Pod 中启动新的 K8s Pod - Start new K8s Pod within K8s Pod without “Privileges” 如何从本地docker镜像启动新的k8s pod? - How to start new k8s pod from LOCAL docker image? 如何在不杀死原始Pod的情况下改变k8s的Pod倾斜度? - How to change k8s's pods limts without killing the original pod? k8s 如何知道 Pod 内进程的目标端口? - How k8s knows the target port of a process inside a Pod? 如何创建具有特定配置的 k8s 自定义 pod? - How to create a k8s custom pod with a specific configuration? 是否可以在 Docker Swarm 或 k8s 上运行循环? - is it possible Running loop on Docker Swarm or k8s?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM