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?
The SHELL instruction allows the default shell used for the shell form of commands to be overridden. The default shell on Linux is ["/bin/sh", "-c"] , and on Windows is ["cmd", "/S", "/C"] . The SHELL instruction must be written in JSON form in a Dockerfile.
To remove the image, you first need to list all the images to get the Image IDs, Image name and other details. By running simple command docker images -a or docker images . After that you make sure which image want to remove, to do that executing this simple command docker rmi <your-image-id> .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With