Running Streamlit in Docker

Iโ€™m trying to run a Streamlit app in a docker container. When I start the container, I get the Streamlit email prompt (see image), but Iโ€™m unable to enter anything into it, as the terminal automatically exits to a new line. As a result, the application does not appear to run. How do I get around this?

Hey Karl!

Thatโ€™s a great catch โ€” we should add something about that to our docs.

The way we address this right now is by passing the credentials via the Dockerfile:

RUN bash -c 'echo -e "\
[general]\n\
email = \"your-email@domain.com\"\n\
" > /root/.streamlit/credentials.toml'

Or, if you donโ€™t want to pass your actual email, you can use an empty string.


In the future we will probably also provide an API for passing in credentials via the command line. Hereโ€™s a Github issue I just created, so you can follow our progress :slight_smile:

1 Like

This is currently returning the error

bash: /root/.streamlit/credentials.toml: No such file or directory

Would the file path be different for a Docker build? Or possibly a root permissions issue?

Oh, I think you just have to mkdir /root/.streamlit in the Dockerfile.

So thatโ€™s:

RUN mkdir -p /root/.streamlit

RUN bash -c 'echo -e "\
[general]\n\
email = \"your-email@domain.com\"\n\
" > /root/.streamlit/credentials.toml'
1 Like

That made it work. Thanks!

2 Likes