Deploying a free Python Dash Open Source app from a Docker container with Gunicorn

L. D. Nicolas May
3 min readJul 20, 2020
Unicorn! This one’s not green, though! (https://gunicorn.org/)

Do you need to deploy a Dash app without plunking down the cash for Dash Enterprise? Here’s the straightforward steps I used to deploy a simple test app in a Docker container. The container runs on a RedHat virtual machine provisioned by my employer’s sysadmins.

1. Create App

Use https://dash.plotly.com/layout to create an initial app.py file. However, we need to make a couple of changes.

First, in order to deploy this using Gunicorn, we need to have access to the Flask app underneath Dash. On the Dash deployment page (https://dash.plotly.com/deployment), you’ll see you need to add the line server = app.server.

Some folks reported trouble deploying the app with the default host='127.0.0.1' argument in the run_server method, so let’s use host='0.0.0.0' (per ) and use port 8080 instead of the default port 8050.

Here’s the code for app.py:

# -*- coding: utf-8 -*-

# Run this app with `python app.py` and
# visit http://[your-ip-or-domain-name]:8080/ in your web browser.

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd

external_stylesheets = [
'https://codepen.io/chriddyp/pen/bWLwgP.css'
]

app =

--

--

No responses yet