Docker image error: "/bin/sh: 1: [python,: not found"

I had similar issue, but I didn't have any ' or " chars in docker run command in my case. But I found the solution to repair that issue and maybe will help you in similar case in future:

  1. Clear all unnecessary whitespace chars from Dockerfile
  2. Clear all cached images from this Dockerfile
  3. Build and run new image

If you don't clear cached images, docker will use cached image with some crazy whitespace chars, which was created the same error message like the subject of the thread.


I had the same error. But in my case it was syntax error in command.
I had a missing comma ","
CMD ["python" "app.py"]
instead of
CMD ["python", "app.py"]

Validating the yaml file format can help in this case. Can use any online yaml validator.


I have resolved my issue on my Mac by changing

CMD ["python", "app.py"]

to

CMD python app.py

Use " instead of ' in CMD. (Documentation)