Skip to content
Advertisement

How to create a Dockerfile for streamlit app

I am aiming to deploy a web-app written with Sreamlit,

File Structure

I can run this on my local machine by running streamlit run Home.py in my command line.

However, I’m not sure how to create the docker file.

Any advice?

Advertisement

Answer

In order to Dockerise your app you need two files:

  1. Dockerfile : describes the image structure,
  2. docker-compose.yml : describes how to make a container from that image (Dockerfile)

The answer of Javier Roger is providing a very minimal Dockerfile that seems to work:

JavaScript

If you combine this answer with the following docker-compose then you have a nice container containing your app:

JavaScript

Please note that both Dockerfile and docker-compose.yml should be placed in the root of your app.

To run the app just cd to the root dir and run:

JavaScript

if docker compose is not installed please use:

JavaScript

In case that you cannot install it so easily use this link

Advertisement