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 ./projects.thux.it/requirements.txt /opt/app/requirements.txt RUN pip3 install -r /opt/app/requirements.txt COPY ./projects.thux.it /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"] EXPOSE 8000 #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 manage.py the handler for django interaction) and as a long-term container (uwsgi –ini uwsgi.ini). I use docker-compose as follows:
web: image: thux-projects:3.5 build: . ports: - "8001:8000" volumes: - ./projects.thux.it/web/settings:/opt/app/web/settings - ./manage.py:/opt/app/manage.py - ./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
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