Saturday, February 26, 2022

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

Issue

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?


Solution

Use " instead of ' in CMD. (Documentation)



Answered By - Aleksandr Kovalev
Answer Checked By - Willingham (WPSolving Volunteer)