title: Warning message "back-off restarting failed container" while adding environment variable in dockerfile? why?
body: <p>We're using Gitlab for CI/CD. I'll include the script which we're using gitlab ci-cd file</p>
  <pre><code>services:
    - docker:19.03.11-dind
  workflow:
    rules:
      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == &quot;developer&quot; || $CI_COMMIT_BRANCH == &quot;stage&quot;|| ($CI_COMMIT_BRANCH =~ (/^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i))
        when: always
      - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH != &quot;developer&quot; || $CI_COMMIT_BRANCH != &quot;stage&quot;|| ($CI_COMMIT_BRANCH !~ (/^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i))
        when: never 
  stages:
    - build
    - Publish
    - deploy
  cache:
    paths:
      - .m2/repository
      - target
  
  build_jar:
    image: maven:3.8.3-jdk-11
    stage: build
    script: 
      - mvn clean install package -DskipTests=true
    artifacts:
      paths:
        - target/*.jar
  
  docker_build_dev:
    stage: Publish
    image: docker:19.03.11
    services:
      - docker:19.03.11-dind      
    variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
    script: 
      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
      - docker build -t $IMAGE_TAG .
      - docker push $IMAGE_TAG
    only:
      - /^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i
      - developer
  
  docker_build_stage:
    stage: Publish
    image: docker:19.03.11
    services:
      - docker:19.03.11-dind   
    variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
    script: 
      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
      - docker build -t $IMAGE_TAG .
      - docker push $IMAGE_TAG   
    only:
      - stage
  
  deploy_dev:
    stage: deploy
    image: stellacenter/aws-helm-kubectl
    variables:
      ENV_VAR_NAME: development  
    before_script:
      - apt update
      - apt-get install gettext-base
      - aws configure set aws_access_key_id ${DEV_AWS_ACCESS_KEY_ID}
      - aws configure set aws_secret_access_key ${DEV_AWS_SECRET_ACCESS_KEY}
      - aws configure set region ${DEV_AWS_DEFAULT_REGION}
    script:
      - sed -i &quot;s/&lt;VERSION&gt;/${CI_COMMIT_SHORT_SHA}/g&quot; patient-service.yml     
      - mkdir -p  $HOME/.kube
      - cp $KUBE_CONFIG_DEV $HOME/.kube/config
      - chown $(id -u):$(id -g) $HOME/.kube/config 
      - export KUBECONFIG=$HOME/.kube/config
      - cat patient-service.yml | envsubst | kubectl apply -f patient-service.yml -n ${KUBE_NAMESPACE_DEV}
    only:
      - /^([A-Z]([0-9][-_])?)?SPRINT(([-_][A-Z][0-9])?)+/i
      - developer
  
  deploy_stage:
    stage: deploy
    image: stellacenter/aws-helm-kubectl
    variables:
      ENV_VAR_NAME: stage
    before_script:
      - apt update
      - apt-get install gettext-base
      - aws configure set aws_access_key_id ${DEV_AWS_ACCESS_KEY_ID}
      - aws configure set aws_secret_access_key ${DEV_AWS_SECRET_ACCESS_KEY}
      - aws configure set region ${DEV_AWS_DEFAULT_REGION}
    script:
      - sed -i &quot;s/&lt;VERSION&gt;/${CI_COMMIT_SHORT_SHA}/g&quot; patient-service.yml    
      - mkdir -p  $HOME/.kube
      - cp $KUBE_CONFIG_STAGE $HOME/.kube/config
      - chown $(id -u):$(id -g) $HOME/.kube/config 
      - export KUBECONFIG=$HOME/.kube/config
      - cat patient-service.yml | envsubst | kubectl apply -f patient-service.yml -n ${KUBE_NAMESPACE_STAGE}
    only:
      - stage
  </code></pre>
  <p>According to the script, we just merged the script not to face conflicts/clashes for stage and development enviornment while deployment. Previously, we having each docker files for each environment(stage and developer). Now I want to merge the dockerfile &amp; k8's yml file also, I merged, but the dockerfile is not fetching. Having clashes (its showing the warning message &quot;back-off restarting failed container&quot;after pipeline succeeds) in Kubernetes. I don't know how to clear the warning in Kubernetes. I'll enclose the docker file and yml file for your reference which I merged.</p>
  <p><strong>k8's yaml file</strong></p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: patient-app
    labels:
      app: patient-app
  spec:
    replicas: 1
    selector:
      matchLabels:
        app : patient-app
    template:
      metadata:
        labels:
          app: patient-app
      spec:
        containers:
        - name: patient-app
          image: registry.gitlab.com/stella-center/backend-services/patient-service:&lt;VERSION&gt;
          imagePullPolicy: Always
          ports:
            - containerPort: 8094
          env:
          - name: ENV_VAR_NAME
            value: &quot;${ENV_VAR_NAME}&quot;          
        imagePullSecrets:
          - name:  gitlab-registry-token-auth
  
  ---
  
  apiVersion: v1
  kind: Service
  metadata:
    name:  patient-service
  spec:
    type: NodePort
    selector:
      app:  patient-app
    ports:
    - port:  8094
      targetPort:  8094
  </code></pre>
  <p><strong>Docker file</strong></p>
  <pre><code>FROM maven:3.8.3-jdk-11 AS MAVEN_BUILD
  COPY pom.xml /build/
  COPY src /build/src/
  WORKDIR /build/
  RUN mvn clean install package -DskipTests=true
  FROM openjdk:11
  WORKDIR /app
  COPY --from=MAVEN_BUILD /build/target/patient-service-*.jar /app/patient-service.jar
  ENV PORT 8094
  EXPOSE $PORT
  ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active=$ENV_VAR_NAME&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;]
  </code></pre>
  <p>In dockerfile , before we used the last line, we used before,</p>
  <pre><code> ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active=development&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;] -for developer dockerfile
      ENTRYPOINT [&quot;java&quot;,&quot;-Dspring.profiles.active=stage&quot;,&quot;-jar&quot;,&quot;/app/patient-service.jar&quot;] - for stage dockerfile 
  </code></pre>
  <p>At the time, its working fine, I'm not facing any issue on Kubernetes. I just added  environment variable to fetch along with whether development or stage .I don't know why the warning is happening. Please help me to sort this out . Thanks in advance.</p>
  <p><strong>kubectl describe pods</strong></p>
  <pre><code>&gt; Name:         patient-app-6cd8c88d6-s7ldt Namespace:   
  &gt; stellacenter-dev Priority:     0 Node:        
  &gt; ip-192-168-49-35.us-east-2.compute.internal/192.168.49.35 Start Time: 
  &gt; Wed, 25 May 2022 20:09:23 +0530 Labels:       app=patient-app
  &gt;               pod-template-hash=6cd8c88d6 Annotations:  kubernetes.io/psp: eks.privileged Status:       Running IP:          
  &gt; 192.168.50.146 IPs:   IP:           192.168.50.146 Controlled By:  ReplicaSet/patient-app-6cd8c88d6 Containers:   patient-app:
  &gt;     Container ID:   docker://2d3431a015a40f551e51285fa23e1d39ad5b257bfd6ba75c3972f422b94b12be
  &gt;     Image:          registry.gitlab.com/stella-center/backend-services/patient-service:96e21d80
  &gt;     Image ID:       docker-pullable://registry.gitlab.com/stella-center/backend-services/patient-service@sha256:3f9774efe205c081de4df5b6ee22cba9940f974311b094
  &gt; 2a8473ee02b9310b43
  &gt;     Port:           8094/TCP
  &gt;     Host Port:      0/TCP
  &gt;     State:          Running
  &gt;       Started:      Wed, 25 May 2022 20:09:24 +0530
  &gt;     Ready:          True
  &gt;     Restart Count:  0
  &gt;     Environment:    &lt;none&gt;
  &gt;     Mounts:
  &gt;       /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-sxbzc (ro) Conditions:   Type              Status  
  &gt; Initialized       True   Ready             True   ContainersReady  
  &gt; True   PodScheduled      True Volumes:   kube-api-access-sxbzc:
  &gt;     Type:                    Projected (a volume that contains injected data from multiple sources)
  &gt;     TokenExpirationSeconds:  3607
  &gt;     ConfigMapName:           kube-root-ca.crt
  &gt;     ConfigMapOptional:       &lt;nil&gt;
  &gt;     DownwardAPI:             true QoS Class:                   BestEffort Node-Selectors:              &lt;none&gt; Tolerations:           
  &gt; node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
  &gt;                              node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events:                      &lt;none&gt;
  </code></pre>