I have a container that I have defined with an CMD and an ENTRYPOINT in Docker. When I run the following command my container runs with no issues whatsoever.

docker run --rm -ti custom-container:latest

Here is the definition for my container:

FROM mcr.microsoft.com/powershell:6.2.3-ubuntu-bionic
COPY . /app

CMD ["/app/Start-Test.ps1"]
ENTRYPOINT ["pwsh", "-f", "/app/Start-Test.ps1"]

The script Start-Test.ps1 is just an infinite loop that writes Hello World! to host.


When I go to run my container in Kubernetes, my container refuses to run.

Kubernetes is able to pull my image and it attempts to spin up the container, but I keep getting a status of BackedOff from Kubernetes.

I've gone through and tried to figure out why this is happening because the container runs perfectly fine in Docker.

I only have issues when I try to run the container in Kubernetes.

Here is the definition for my Kubernetes deployment.

apiVersion: extensions/v1beta1
kind: Deployment
  name: my-custom-container
  replicas: 1
      app: my-custom-container
        app: my-custom-container
      - name: my-custom-container
        image: repository-url.io/custom-container:latest
      - name: regcred


What is the issue preventing my container from running when it runs with no problems in Docker?

Additionally, yes I would like to use PowerShell as my entry point. It should be possible to use any scripting langauge (bash, Ruby, Python, Perl, etc) as an entry point.

  • 1
    What is the contents of your K8S logs? kubectl logs <pod name>. Please add the log data to your question. Feb 4 '20 at 3:29

To debug this, check the container logs and the container events.

  • kubectl get pods
  • Find your pod name.
  • kubectl logs
  • If logs don't make it obvious...
  • kubectl get events

If you deployed into a namespace, make sure to add -n to all commands.

This should reveal basically everything. If you're stuck, you can also browse around the k8s dashboard if you haven't yet. But that probably wouldn't reveal much more than the CLI is with these commands.


K8s works with concept of Health Check, in your application you have some port or command/trigger that K8s can monitoring? Maybe because of that your container is not works.

  1. It looks like your dockerfile has both CMD and ENTRYPOINT, so it’s highly likely that what gets invoked as a commsnd is pwsh -f /app/Start-Test.ps1 /app/Start-Test.ps1. It could be that this command gives an error, kubectl describe <your-pod> might shed some light onto what’s going on. Check this answer for details on difference between CMD and ENTRYPOINT
  2. If you’re getting ImagePullBackOff, then image might be missing from the registry or secrets are invalid.

Hope this helps


When running PowerShell as the ENTRYPOINT for the container PowerShell should be executed as:

ENTRYPOINT ["pwsh", "-NoExit", "-File", "/app/Start-Test.ps1"]

The short form of each of those parameters can be used. Additionally, the -NoExit flag will help with debugging the issue in for your deployment. The reason the -NoExit flag helps is the deployment stays alive long enough for you to confirm the logs and the container health.

This answer along with answers from Alexey Skolyarov and John Humphreys to debug and solve my issue.

Your Answer

