question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Streamlit app running inside Docker doesn't show logs

See original GitHub issue

Summary

I can’t seem to manage to get logging working when running a streamlit app inside Docker. Neither logging calls nor prints are not shown on console or with docker logs.

Steps to reproduce

  1. Clone git@github.com:danimateos/streamlitdockerlog.git, cd into directory

  2. Docker build

docker build -t strtest:latest .
  1. Docker run
docker run -p 80:8501  strtest:latest
  1. Go to localhost on browser.

  2. Watch docker logs:

docker logs [your_container_name]

Expected behavior:

Three lines appear in the docker logs each time the browser tab is reloaded because of the following code in app.py:

logging.info('info')
logging.error('error')
print('print')

Actual behavior:

Nothing appears with docker logs. When the app is run with streamlit run app.py, the three lines do appear.

Is this a regression?

Not that I know.

Debug info

  • Streamlit version: 0.58
  • Python version: 3.8.2
  • Using Conda? Yes, as described in the Dockerfile
  • OS version: Ubuntu 20.04
  • Browser version: Chrome version 81.0.4044.122 (Official Build) (64-bit)

Additional information

Possibly related to #1321 or #447

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
MarcSkovMadsencommented, Aug 20, 2020

Do you have

ENV PYTHONUNBUFFERED=1

in your Dockerfile @danimateos ? You will need that. I don’t exactly understand why but I once spent a lot of time investigating why “kubernetes did not give me logs back” from a Python docker image 😃

Maybe you need to add

ENV PYTHONIOENCODING=UTF-8
1reaction
danimateoscommented, Jul 1, 2020

Hi! Any news on this! I would really like to be able to keep track of how people are using my web app…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streamlit + Docker + Logging + View Logs
This does not show logs in real time, but I've made a simple demo of how to make the logs show in real-time,...
Read more >
Error running streamlit docker
I've been trying to create an docker image to run fbprohet and streamlit. When i run the docker run command i get the...
Read more >
Docker logging while running Streamlit
Hi, I've managed to get Streamlit to successfully run within a Docker container. My script prints out certain things when certain operations ...
Read more >
Saving logs? - Using Streamlit
I have a similar, but slightly different problem. Running my app locally, I can download (from within the app) a log file containing...
Read more >
Deploy Streamlit using Docker
You typically use a VPN to log onto your corporate network and access resources there. You could run your Streamlit app on a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found