sean harricharan
sean harricharan

Reputation: 63

How to resolve this issue when building a docker image of a Django app

I'm trying to dockerize my django app but I'm having an issue where the CMD isn't recognizing the "python3" command.

I created the requirements.txt, Dockerfile and .dockerignore file in the root directory and the Dockerfile contains the follow:

FROM python:3.8-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

COPY . .

CMD [
    "python3",
    "manage.py",
    "runserver",
    "0.0.0.0:8000"
]

I'm using VS Code and the intellisense is highlighting all the items in the CMD list as an error. When I try to build the image, I'm getting the following error:

Error response from daemon: dockerfile parse error line 12: unknown instruction: "PYTHON3",

Can anyone provide any possible solutions to the problem?

Upvotes: 0

Views: 327

Answers (1)

ErnestBidouille
ErnestBidouille

Reputation: 1146

Because docker doesn't support not inline commands natively.

You should do it like this:

CMD [              \
    "python3",     \
    "manage.py",   \
    "runserver",   \
    "0.0.0.0:8000" \
]

# OR

CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]

Upvotes: 2

Related Questions