вот работающий пример: ( ... правда с переменой пользователя не заморачивался ) :
Dockerfile
# supervisor docker example
FROM jfloff/alpine-python
RUN apk add --no-cache supervisor && rm -rf /var/lib/apt/lists/*
RUN sed -i 's/^\(\[supervisord\]\)$/\1\nnodaemon=true/' /etc/supervisord.conf
RUN mkdir -p /etc/supervisor.d/
COPY server.py server.py
COPY agent.conf etc/supervisor.d/agent.ini
# for server.py
ARG SERVICE_PORT=8080
ENV SERVICE_PORT=$SERVICE_PORT
EXPOSE $SERVICE_PORT
# NOTE: not ENTRYPOINT
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
agent.conf
[program:server]
autostart = true
autorestart = true
user = root
environment = PYTHONUNBUFFERED=1
directory = /
command = python server.py
stderr_logfile=/var/log/server.err
stdout_logfile=/var/log/server.out
команды
docker build -t example -f Dockerfile .
docker rm example_container
docker run -it --name example_container example
2020-12-19 18:00:54,578 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-12-19 18:00:54,578 INFO Included extra file "/etc/supervisor.d/agent.ini" during parsing
2020-12-19 18:00:54,588 INFO RPC interface 'supervisor' initialized
2020-12-19 18:00:54,588 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-12-19 18:00:54,589 INFO supervisord started with pid 6
2020-12-19 18:00:55,594 INFO spawned: 'server' with pid 8
2020-12-19 18:00:56,597 INFO success: server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
docker exec -it example_container supervisorctl status server
server RUNNING pid 8, uptime 0:00:14
docker exec -it example_container sh
ls /var/log/
server.err server.out supervisord.log
ps ax | grep pytho[n]
6 root 0:00 {supervisord} /usr/bin/python3 /usr/bin/supervisord -c /etc/supervisord.conf
8 root 0:00 python server.py