I have the following 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. so I usually use docker run -d -t
to run it. 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.
When adding the following entrypoint,
ENTRYPOINT [ "tail", "-f", "/dev/null"]
The machine keeps crashing
How can I keep the pod running in background?
Make use of -i
and --tty
option of kubectl run
command.
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.
apiVersion: v1
kind: Pod
metadata:
name: testpod
spec:
containers:
- name: testpod
image: testimage
stdin: true
tty: true
More info here.