# Deployment on Docker

**URL:** <https://community.plotly.com/t/deployment-on-docker/38854>\
**Category:** Dash Python\
**Created:** [May 4, 2020, 11:06am UTC](https://community.plotly.com/t/deployment-on-docker/38854 "2020-05-04T11:06:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarah.decock2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sarah.decock2](https://community.plotly.com/u/Sarah.decock2)\
**Post date:** [May 4, 2020, 11:06am UTC](https://community.plotly.com/t/deployment-on-docker/38854/1 "2020-05-04T11:06:37Z")

</div>

Hi,

I would like to deploy my Dash app on Docker. My folder structure:

- application
  - Dockerfile
  - requirement.txt
  - index.py

My index.py

```auto
if __name__ == ' __main__':
    app.run_server(host='0.0.0.0', port=8050, debug=True)

```

My Dockerfile

```auto
FROM python:3.7

RUN mkdir /application
WORKDIR /application

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY ./ ./
EXPOSE 8050

CMD ["python", "./index.py"]

```

The commands for docker:

```auto
docker build -t test_app .
docker run test_app 0.0.0.0:8050 -d

```

Error: docker: Error response from daemon: OCI runtime create failed: container\_linux.go:349: starting container process caused “exec: “0.0.0.0:8050”: executable file not found in $PATH”: unknown.

What am I doing wrong?

Kind regards

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [May 4, 2020, 11:23am UTC](https://community.plotly.com/t/deployment-on-docker/38854/2 "2020-05-04T11:23:40Z")

</div>

In deployment, i would recommend using a production grade web server such as gunicorn. Assuming that gunicorn is installed (just add it to the requirement.txt file), you could start it in your docker container like this (here i assume that there is a application file app.py in which the Flask server is called `app`),

```auto
CMD ["gunicorn", "--workers=1", "--threads=1", "-b 0.0.0.0:8000", "app:app"]

```

---

<div class="post-metadata">

**Author:** ![Sarah.decock2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sarah.decock2](https://community.plotly.com/u/Sarah.decock2)\
**Post date:** [May 6, 2020, 12:34pm UTC](https://community.plotly.com/t/deployment-on-docker/38854/3 "2020-05-06T12:34:53Z")

</div>

Thanks for the answer but I’m still getting the same error…

My Dockerfile:

```auto
FROM python:3.7

RUN mkdir /app
WORKDIR /app

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY ./ /app
EXPOSE 8050

CMD ["gunicorn", "--workers=1", "--threads=1", "-b 0.0.0.0:8050", "index:app.server"]

```

I have added gunicorn into the requirements.txt

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [May 6, 2020, 1:37pm UTC](https://community.plotly.com/t/deployment-on-docker/38854/4 "2020-05-06T13:37:41Z")

</div>

I guess there is a mismatch between how you copy the files and the run command. Can you post the content of index.py?

---

<div class="post-metadata">

**Author:** ![Sarah.decock2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sarah.decock2](https://community.plotly.com/u/Sarah.decock2)\
**Post date:** [May 7, 2020, 8:08am UTC](https://community.plotly.com/t/deployment-on-docker/38854/5 "2020-05-07T08:08:16Z")

</div>

This is the content of my image:

 ![afbeelding](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/e/e983e92c1ad8670b3383a2abf4610c22ca311f80.png)

I followed this [link](https://dash.plotly.com/urls) for multi-paging:  
My index.py

```auto
import uuid
import dash_core_components as dcc
import dash_html_components as html
import dash_resumable_upload
from dash.dependencies import Input, Output, State
import dash_flexbox_grid as dfx
import dash
import os
from app import app
from Tabs import home, data_overview, header, evaluation
from dash.exceptions import PreventUpdate

def serve_layout():
    session_id = str(uuid.uuid4())
    return html.Div([
    header.layout,
    dcc.Store(id='options_store', storage_type='session'),
    dcc.Store(id='session_id', storage_type='session', data=dict(id=session_id)),
    dfx.Grid(id='page-content', fluid=True, children=[
    ])
])

app.layout = serve_layout

@app.callback(Output('page-content', 'children'),
              [Input('tabs_navbar', 'value')],
              [State('session_id', 'data'), State('options_store', 'data')]
)
def display_page(value, session_id, data):
    # Load layout based on selected tab
    session_id = session_id.get('id')

    if value == 'home':
        return home.layout
    elif value == 'data-overview':
        return data_overview.layout
    elif value == 'evaluation':
        return evaluation.layout
    else:
        return '404'

if __name__ == ' __main__':
    app.run_server(debug=True)

```

My app.py:

```auto
import dash
import uuid
import dash_html_components as html
import dash_core_components as dcc
import flask
import dash_resumable_upload

external_stylesheets = ['https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css', 'https://use.fontawesome.com/releases/v5.7.2/css/all.css']
external_scripts = ['http://code.jquery.com/jquery-1.7.1.min.js']
server = flask.Flask( __name__ )
app = dash.Dash( __name__ , external_stylesheets=external_stylesheets, external_scripts=external_scripts, server=server)

def serve_layout():
    session_id = str(uuid.uuid4())
    return html.Div([
    dcc.Store(id='session_id', storage_type='session', data=dict(id=session_id)),
    ])

dash_resumable_upload.decorate_server(app.server, 'Storage/Temporary')
app.layout = serve_layout

app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True

```

---

<div class="post-metadata">

**Author:** ![Sarah.decock2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sarah.decock2](https://community.plotly.com/u/Sarah.decock2)\
**Post date:** [May 7, 2020, 8:18am UTC](https://community.plotly.com/t/deployment-on-docker/38854/6 "2020-05-07T08:18:45Z")

</div>

I have run: docker image inspect test\_dashboard  
And I saw this:

 ![afbeelding](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/a/a38ff53d2f936111132aa9c59df27dcba9a07883.png)

Could it be that this causes the error “executable file not found in $PATH”? (I’m new in Docker)

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [May 7, 2020, 8:53am UTC](https://community.plotly.com/t/deployment-on-docker/38854/7 "2020-05-07T08:53:48Z")

</div>

I am not sure what is going wrong in your example. It might be easier to start from a working example to figure it out. As a reference, i have created a MWE where the app is simply,

```auto
import dash
import dash_html_components as html

from flask import Flask

server = Flask( __name__ )
app = dash.Dash(server=server)
app.layout = html.Div("Hello world.")

if __name__ == ' __main__':
    app.run_server()

```

with a corresponding requirements.txt

```auto
dash==1.12.0
gunicorn
flask

```

and a simple Dockerfile,

```auto
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:8000", "app:server"]

```

You can download the files in the link below along with a docker-compose file for easy deployment.

> **[thedirtyfew/dash-docker-mwe](https://github.com/thedirtyfew/dash-docker-mwe)**
>
> Contribute to thedirtyfew/dash-docker-mwe development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Sarah.decock2](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sarah.decock2](https://community.plotly.com/u/Sarah.decock2)\
**Post date:** [May 7, 2020, 9:25am UTC](https://community.plotly.com/t/deployment-on-docker/38854/8 "2020-05-07T09:25:28Z")

</div>

Thanks for the example!
