Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Azure deployment with Docker and Gunicorn

Hi,

I deployed a Dash application within a docker container to Azure. When I set the Dockerfile to gunicorn it won’t run on Azure while it is ok on the localhost. Versions that use the development server are running ok on both localhost and Azure.

Here is the app.py

import dash
import dash_html_components as html
import dash_core_components as dcc

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

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
server = app.server

app.layout = html.Div(children=[
    html.H1(children='Hello Dash3'),

    html.Div(children='''
        Dash: Docker, Gunicorn, Azure
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montreal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])
if __name__ == '__main__':
    app.run_server()

This is the Dockerfile

FROM python:3.8-slim-buster

# Create a working directory.
RUN mkdir wd
WORKDIR wd

# Install Python dependencies.
COPY requirements.txt .
RUN pip3 install -r requirements.txt

# Copy the rest of the codebase into the image
COPY . ./

# Finally, run gunicorn.
CMD [ "gunicorn", "--workers=5", "--threads=1", "-b 0.0.0.0:3001", "app:server"]

The browser shows this error: “502 - Web server received an invalid response while acting as a gateway or proxy server.”

I read several posts on this, but did not find an approriate CMD setting.

TIA