I'm trying to run a UWSGI server from a Docker container. I've had success, but I'm hitting a wrinkle in that my entrypoint script will still be running as root with PID 1 after container startup, when I'd rather have the initial /bin/bash
process be replaced by the UWSGI processes:
bash-4.4# ps aux
PID USER TIME COMMAND
1 root 0:00 {docker-entrypoi} /bin/bash /usr/local/bin/docker-entrypoint.sh
19 myuser 0:00 uwsgi --ini /opt/mysite/uwsgi.ini
21 myuser 0:00 uwsgi --ini /opt/mysite/uwsgi.ini
22 myuser 0:00 uwsgi --ini /opt/mysite/uwsgi.ini
24 myuser 0:02 python3 ./manage.py qcluster
28 myuser 0:00 python3 ./manage.py qcluster
29 myuser 0:00 python3 ./manage.py qcluster
30 myuser 0:00 python3 ./manage.py qcluster
31 myuser 0:00 python3 ./manage.py qcluster
32 myuser 0:00 python3 ./manage.py qcluster
33 myuser 0:00 python3 ./manage.py qcluster
34 myuser 0:00 python3 ./manage.py qcluster
I've tried some variations with exec
and su-exec
, but I'm still hitting the above. I need to supply my PEM passphrase to UWSGI on startup, so I've been using syntax like so:
echo $PEM_PASSPHRASE | exec uwsgi --ini /opt/mysite/uwsgi.ini
This works fine to get up and running, but I still get the PID 1 /bin/bash
process running, with the UWSGI processes as children below. I feel like I'm missing some obvious detail to actually get the bash process to be replaced by the UWSGI processes via exec
.
For what it's worth, I'm only using ENTRYPOINT in the Dockerfile, and not CMD:
ENTRYPOINT ["docker-entrypoint.sh"]
Any pointers in the right direction would be greatly appreciated.
exec uwsgi --ini /opt/mysite/uwsgi.ini < <(echo "$PEM_PASSPHRASE")
and that did the trick. Now PID 1 is one of the uwsgi processes, now running under the correct user and not root. Never would I have put that together to figure that out. Thanks so much for the background knowledge; exactly what I was looking for. Cheers! – Nanceynanchang