S
Solara2w ago
Jovan

Logging in docker

Hi, I have big troubles getting solara logging to work within docker. I guess solara run does some redirect away from pid1? I do specify --log-level in my entrypoint but still nothing.. I do not do anything special with respect to logging, just want to see the solara (+ my own logs) from the app on the docker dashboard etc.. Is there some hidden config i need to adjust somewhere, or is this supported at all.. Would be very much appreciated!
1 Reply
Jovan
JovanOP2w ago
I think i understand what is happening.. since i am using "mamba run .." my solara process is not a pid1 process.. so one needs to find a way around this probably. actually.. probably solara does something with the logging (that matters when stuff are in docker), since a simple mamba run.. with a test file works well and logging is capture by docker ENTRYPOINT ["mamba", "run", "-n", "my-env", "python", "test_log.py"] works but ENTRYPOINT ["mamba", "run", "-n", "my-env", "solara", "run", "app.py", "--host=0.0.0.0", "--production", "--port", "8765", "--log-level", "info"] does not Ok i figured it out, for anyone that might be struggling with this in the future: If you have a dockerfile trying to set up a solara webapp (for production use), if you do something like
ENTRYPOINT ["mamba", "run", "-n", "my-env", "solara", "run", "app.py", "--host=0.0.0.0", "--production", "--port", "8765", "--log-level", "info"]
ENTRYPOINT ["mamba", "run", "-n", "my-env", "solara", "run", "app.py", "--host=0.0.0.0", "--production", "--port", "8765", "--log-level", "info"]
the logs will not pooled by docker, since mamba run lives in a separate process and spans a new process that runs solara.. Something similar happens with uv run if that is more your thing. If you use CMD [...] even if solara does not run in pid1 the logs will be properly found. However, for production use, ENTRYPOINT is preferred.. so at the end .. the best solution I could find after some research is the following.. install tini and supervisordfrom apt-get if your base image does not already have it and do something like
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/supervisord", "-n", "-c", "/app/supervisord.conf"]
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/supervisord", "-n", "-c", "/app/supervisord.conf"]
you will need to have a supervisord.config file and possibly some startup.sh script. If you are not familiar with these, read about them, quite useful in this set up (your neighbourhood LLMs also know about them). example
[supervisord]
nodaemon=true
user=root

[program:lexilingo]
command=/app/startup.sh
directory=/app
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=10
killasgroup=true
stopasgroup=true
# Add these lines for logging
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
# Ensure output is properly captured and forwarded
redirect_stderr=true
stdout_logfile_backups=0
stderr_logfile_backups=0
[supervisord]
nodaemon=true
user=root

[program:lexilingo]
command=/app/startup.sh
directory=/app
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=10
killasgroup=true
stopasgroup=true
# Add these lines for logging
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
# Ensure output is properly captured and forwarded
redirect_stderr=true
stdout_logfile_backups=0
stderr_logfile_backups=0
To the moderators: you can consider thi issue closed. Thanks!

Did you find this page helpful?