CrashLoopBackOff when args are added in Kubernetes

This deployment is fine until I add args (added below) to the deployment. I can’t figure out why it would turn into a CrashLoopError when adding simple args. I even tried to echo Hello World and it still results in a CrashLoopError.

There are no logs and when I describe the pod it shows:

  • Can I get ip address inside my docker container?
  • Permissions error running Java Timezone Updater JAR in Dockerfile
  • Docker pull from inside vagrant box requires constant pressing of key
  • Illegal tokens added after modifying the file inside data volume
  • docker-compose up Permission denied on Windows
  • Cassandra 2.1.11 doesn't start in docker container
  • Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "nginx" with CrashLoopBackOff: "Back-off 10s restarting failed container=nginx pod=nginx-2247906467-r9znh_dave-testing(98c3999e-c39b-11e6-936e-0050568b4a68)"
    

    and here is the YAML:

    - kind: Deployment
      apiVersion: extensions/v1beta1
      metadata:
        name: nginx
      spec:
        replicas: 1
        template:
          metadata:
            labels:
              name: nginx
              version: "1.9"
          spec:
            containers:
            - name: nginx
              imagePullPolicy: Always
              image: "nginx:1.9"
              ports:
              - containerPort: 80
              args:
              - "echo $NGINX_CONF > /etc/nginx/nginx.conf"
              env:
              - name: NGINX_CONF
                valueFrom:
                  secretKeyRef:
                    name: confs
                    key: nginx
    

  • How do I run multiple commands within a Docker container in Jenkins?
  • How to send a curl in Docker Remote API?
  • Configure sendmail inside a docker container
  • Error initialising MongoDB replica set in Docker container
  • Docker not starting “ could not delete the default bridge network: network bridge has active endpoints”"
  • “Failed to resolve IP”; “Lookup error” in bash script when joining dockerized serf agents
  • One Solution collect form web for “CrashLoopBackOff when args are added in Kubernetes”

    Here is a working version of Kubernetes Pod with nginx alpine docker image:

    apiVersion: v1
    kind: Pod
    metadata:
      name: frontend-nginx-pod
      labels:
        app: nginx-test
    spec:
      containers:
        - name: nginx
          image: nginx:1.11.6-alpine
          ports:
            - containerPort: 80
              name: "http-server"
          args:
          - /bin/sh
          - -c
          - echo "hello" > /usr/share/nginx/html/index.html && nginx "-g daemon off;"
    

    I was getting the same error without listing args as above.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.