I was trying to use the netshoot image with Nginx server image on the same pod.
If I do not include sleep argument to netshoot container,
args:
- sleep
- '9999999999999999999'
the pod status always becomes CrashLoopBackOff. I did not figure out why I have to put sleep argument to sleep current thread in netshoot container. Do containers have to consist of application servers or running jars to retain running status? I think I missed the fundamental point about the running mechanism of containers. Thanks.
apiVersion: apps/v1
kind: Deployment
metadata:
# Define the Deployment Name
name: nginx-deployment
labels:
app: nginx
spec:
# Define the Number of Pods
replicas: 1
# Define the Selector
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers: # Container Details
- name: nginx
image: nginx:latest # Image
ports:
- containerPort: 80
- name: netshoot
image: nicolaka/netshoot:latest
args:
- sleep
- '9999999999999999999'
CodePudding user response:
Containers are a wrapper around a command, and they run until that command exits. The default command for netshoot is zsh
. Like other shells, they run until they reach an exit command, a signal interrupts them, or the input they process returns an EOF. Without any stdin input defined, a container will reach that EOF immediately.
As an aside, a common noop command for containers is tail -f /dev/null
.