creating a docker container that runs forever using bash

If you want to keep printing Hello every few seconds you can use:

apiVersion: v1
kind: Pod
metadata:
  name: busybox2
  labels:
    app: busybox
spec:
  containers:
  - name: busybox
    image: busybox
    ports:
    - containerPort: 80
    command: ["/bin/sh", "-c", "while :; do echo 'Hello'; sleep 5 ; done"]

You can see the output using kubectl logs <pod-name>

Other option to keep a container running without printing anything is to use sleep command on its own, for example:

command: ["/bin/sh", "-ec", "sleep 10000"]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top