Dash callbacks triggering twice on Home page when running in Docker container

I am developing a multi-page dash application. I have ran the application on my local machine, as well as on a Vagrant VM using port forwarding and both have worked seamlessly. However, when I go to containerize my application using Docker and run it in the VM, several callbacks on the initial page fire twice on page load causing the app to not render. I’ve added allow_duplicate=True on these callbacks and still the app won’t load. I’m serving the layout using the technique:
`
def serve_layout()
// content

layout = serve_layout
`

This is the Dockerfile used to build the image:
`FROM python:3.9.6

RUN mkdir -p /app
COPY . /app
WORKDIR /app

ENV PIP_CERT=certs_path

RUN pip --timeout=1000 install -r requirements.txt
WORKDIR /app/src

CMD [“python”, “sitrep.py”]`

Here is my main file:
app = Dash(__name__, use_pages=True, suppress_callback_exceptions=True)

app.layout = html.Div([dash.page_container])

if __name__ == ‘__main__’:
app.run(debug=True,host=‘0.0.0.0’,use_reloader=False)

I’m running Dash 2.13.0 with python 3.9.6.

I’ve resolved this issue. If you import functions from one python module (page) to another, it triggers all of the callbacks on the initial page during the import (even if you just specify the import of a single function). This bug did not present on my local machine or VM, only when I containerized the application with Docker.

1 Like

Hello @lukekasper25,

Welcome to the community!

Glad you figured it out.

Importing into other pages can definitely cause issues, typically it is recommended to use a common location and import the functions from that location.

1 Like

Good suggestion

1 Like