Docker image error: "/bin/sh: 1: [python,: not found"
I'm building a new Docker image based on the standard Ubuntu 14.04 image.
Here's my Dockerfile:
FROM ubuntu:14.04
RUN apt-get update -y
RUN apt-get install -y nginx git python-setuptools python-dev
RUN easy_install pip
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt # only 'django' for now
ENV projectname myproject
EXPOSE 80 8000
WORKDIR ${projectname}
CMD ['python', 'manage.py', 'runserver', '0.0.0.0:80']
When I try to run this image, I get this error...
/bin/sh: 1: [python,: not found
But if I open a shell when running the image, running python
opens the interactive prompt as expected.
Why can't I invoke python
through CMD
in the Dockerfile?
Use "
instead of '
in CMD. (Documentation)
I have resolved my issue on my Mac by changing
CMD ["python", "app.py"]
to
CMD python app.py
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 ofCMD ["python", "app.py"]
Validating the yaml file format can help in this case. Can use any online yaml validator.