Problem deploying streamlit app with Docker

Hi all from France,

I just post my question here because despite all the existing posts on this subject I do not understand the procedure.
For a school project, I use streamlit to build a dashboard, which communicates with a Flask application. I later found that streamlit embeds the Tornado framework directly…

My configuration works well locally, but I have a lot of problems deploying it.

This is what i did :

I built a Docker image with the following files :

  • application_test.csv
  • application_train.csv
  • Dockerfile
  • logo.PNG
  • requirements.txt is the file containing the streamlit code is a file containing all the code with Flask. Here Flask works on port 4449

Here is the code of my Dockerfile :

# Python support can be specified down to the minor or micro version
# (e.g. 3.6 or 3.6.3).
# OS Support also exists for jessie & stretch (slim and full).
# See for all supported Python
# tags from Docker Hub.
FROM python:3.7.6-slim-buster

# If you prefer miniconda:
#FROM continuumio/miniconda3

LABEL Name=test_azure Version=0.0.1

# Répeertoire de travail
# Récupération fichiers
COPY . /app

# Using pip:
RUN python3 -m pip install -r requirements.txt
CMD ["python3", "-m", "test_azure"]

# Lance Flask
CMD ["python", ""]

# Lance streamlit
CMD ["streamlit", "run", ""]

Locally, I launch my image and I have a message telling me that streamlit is launched. Unfortunately, nothing appears in my browser at the two proposed URLs.

I am trying to configure the URL in in order to make it public, but I do not understand the procedure.

I have to change the config.toml file but how do I do that?

Could you explain to me how to deploy my application with Docker please?




you’ve to bind ports
you can do it by running something like this

docker run -p 8451:8451 <<image_id_of_container>>

Thank you for your answer.

I managed to deploy my application with a docker on Azure, but I am faced with a new problem, I cannot access (or start) Flask.

ConnectionError: HTTPConnectionPool(host=‘’, port=5000): Max retries exceeded with url: /init_model (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f1504a7ecd0>: Failed to establish a new connection: [Errno 111] Connection refused’))

However I think I configured it well in my dockerfile…

# Lance Flask
CMD ["python", ""]

# Lance streamlit
ENTRYPOINT ["streamlit", "run"]
CMD [""]

start flask and streamlit independently

OK, thanks.

I am a beginner with all this. How can I do this please?

Hello @dracfooza,

From the CMD doc, the CMD method is the default command to run when executing a container, so you can’t have multiple CMD lines in your file.

If I recall correctly, you can either :

  • put all your commands in one CMD with : CMD python && streamlit run
  • create a script with the following lines then : CMD ["./"]
streamlit run
1 Like

@andfanilo Great !!!

Thanks a lot.