[英]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"
Update: 更新:
In case of yaml files make use of stdin
and tty
option. 如果是yaml文件,请使用
stdin
和tty
选项。
apiVersion: v1
kind: Pod
metadata:
name: testpod
spec:
containers:
- name: testpod
image: testimage
stdin: true
tty: true
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.