ERROR: failed to launch: determine start command: when there is no default process a command is required

Issues information

Your issue

Describe here your issue
I cannot deploy. I get this error: ERROR: failed to launch: determine start command: when there is no default process a command is required
Dockerfile content (if any)

FROM python:3.8.0-alpine

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev

RUN pip install --upgrade pip

COPY ./requirements.txt /usr/src/app/requirements.txt

RUN pip install -r requirements.txt

COPY accounts /usr/src/app/

COPY api /usr/src/app/

COPY app /usr/src/app/

COPY core /usr/src/app/

COPY static /usr/src/app/

COPY templates /usr/src/app/

COPY ./manage.py /usr/src/app/manage.py

COPY entrypoint.sh /usr/src/app

EXPOSE 8000

ENTRYPOINT ["./entrypoint.sh"]
`specify here your dockerfile content`

Hi, indeed a CMD command is missing in your Dockerfile to indicate how to start your application.

E.g.

# syntax=docker/dockerfile:1

FROM python:3.8-slim-buster

WORKDIR /app

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

COPY . .

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

You need to add a similar CMD command at the end of your Dockerfile

Thank you for your help. I do however have an entrypoint file. Shouldn’t that just run commands?

It’s a good question, ENTRYPOINT and CMD are not mutually exclusive. It’s even the opposite, most of the time you will use both at the same time. I recommend you to read this article I’ve written explaining a few concepts around Docker.

CMD and ENTRYPOINT are two instructions used to define the process that’s run in your container. ENTRYPOINT sets the process that’s executed when the container first starts. This defaults to a shell, /bin/sh. CMD provides the default arguments for the ENTRYPOINT process.

FROM python:3.8.0-alpine

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev

RUN pip install --upgrade pip

COPY ./requirements.txt /usr/src/app/requirements.txt

RUN pip install -r requirements.txt

COPY accounts /usr/src/app/

COPY api /usr/src/app/

COPY app /usr/src/app/

COPY core /usr/src/app/

COPY static /usr/src/app/

COPY templates /usr/src/app/

COPY ./manage.py /usr/src/app/manage.py

EXPOSE 8000

RUN python manage.py migrate

CMD [ “python”, “manage.py” , “runserver”, “0.0.0.0:8000”]

Hi @Tyler_Suard ,

RUN python manage.py migrate

CMD [ “python”, “manage.py” , “runserver”, “0.0.0.0:8000”]

You can’t run RUN and CMD command together.
I would suggest to put python manage.py migrate into an entrypoint script like entrypoint.sh and put this into your Dockerfile

ENTRYPOINT entrypoint.sh

CMD [ “python”, “manage.py” , “runserver”, “0.0.0.0:8000”]