Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 604
Joe Mornin Avatar asked Sep 22 '15 05:09

Joe Mornin


People also ask

What is sh command in Docker?

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.

How do I remove a docker image?

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> .


2 Answers

Use " instead of ' in CMD. (Documentation)

like image 198
Aleksandr Kovalev Avatar answered Sep 19 '22 06:09

Aleksandr Kovalev


I have resolved my issue on my Mac by changing

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

to

CMD python app.py 
like image 35
srinivasa karadi Avatar answered Sep 23 '22 06:09

srinivasa karadi