docker entrypoint behaviour with django

  django, docker, docker-compose, python, uwsgi

I’m trying to make my first django container with uwsgi. It works as follows:

FROM python:3.5

RUN apt-get update && 
    apt-get install -y && 
    pip3 install uwsgi

COPY ./ /opt/app/requirements.txt
RUN pip3 install -r /opt/app/requirements.txt

COPY ./ /opt/app
COPY ./uwsgi.ini  /opt/app
COPY ./entrypoint /usr/local/bin/entrypoint

ENV PYTHONPATH=/opt/app:/opt/app/apps

WORKDIR /opt/app
ENTRYPOINT ["entrypoint"]

#CMD ["--ini", "/opt/app/uwsgi.ini"]

entrypoint here is a script that detects whether to call uwsgi (in case there are no args) or python manage in all other cases.
I’d like to use this container both as an executable (dj migrate, dj shell, … – dj here is python the handler for django interaction) and as a long-term container (uwsgi –ini uwsgi.ini). I use docker-compose as follows:

    image: thux-projects:3.5
    build: .
      - "8001:8000"
      - ./
      - ./
      - ./uwsgi.ini:/opt/app/uwsgi.ini
      - ./logs:/var/log/django

And I manage in fact to serve the project correctly but to interact with django to “check” I need to issue:

docker-compose exec web entrypoint check

while reading the docs I would have imagined I just needed the arguments (without entrypoint)

Command line arguments to docker run will be appended after
all elements in an exec form ENTRYPOINT, and will override all
elements specified using CMD. This allows arguments to be passed to
the entry point, i.e., docker run -d will pass the -d argument
to the entry point.

The working situation with “repeated” entrypoint:

$ docker-compose exec web entrypoint check
System check identified no issues (0 silenced).

The failing one if I avoid ‘entrypoint’:

$ docker-compose exec web check
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: "check": executable file not found in $PATH": unknown

Source: StackOverflow