Yesterday I discovered that a container was still running on my machine (macOS Monterey). I searched StackOverflow for answers to my issue but anything I tried didn't work.
I did a docker ps
and then a docker stop <container-ID>
but the web app was still running in port 0.0.0.0:80
.
I don't remember when I run this container but it was during the development of a Dash Plotly app.
After the above failed I tried:
docker system prune --all --force --volumes
which removed all containers and images from my system (it did work because the image indeed disappeared from my Docker Desktop list).
I then restarted my computer but the web app was still there.
I then run the command:
sudo lsof -i -P -n | grep 80
which gave me the output:
assistant 480 cconsta1 25u IPv4 0x7f28d5520c917253 0t0 UDP *:*
Google 730 cconsta1 80u IPv6 0x7f28d5520a8477c3 0t0 UDP *:5353
Google 730 cconsta1 89u IPv6 0x7f28d5520a8480f3 0t0 UDP *:5353
Slack\x20 4259 cconsta1 23u IPv4 0x7f28d54d343d66cb 0t0 TCP 192.168.10.1:51807->3.65.102.105:443 (ESTABLISHED)
Slack\x20 4259 cconsta1 26u IPv4 0x7f28d54d339966cb 0t0 TCP 192.168.10.1:51809->3.65.102.105:443 (ESTABLISHED)
httpd 4418 root 4u IPv6 0x7f28d53edaecb713 0t0 TCP *:80 (LISTEN)
httpd 4422 _www 4u IPv6 0x7f28d53edaecb713 0t0 TCP *:80 (LISTEN)
httpd 4431 _www 4u IPv6 0x7f28d53edaecb713 0t0 TCP *:80 (LISTEN)
httpd 4433 _www 4u IPv6 0x7f28d53edaecb713 0t0 TCP *:80 (LISTEN)
httpd 4434 _www 4u IPv6 0x7f28d53edaecb713 0t0 TCP *:80 (LISTEN)
I tried to kill these processes to see if something will work out, sudo kill -9 <PID>
but that didn't work either.
Finally, I cleared my browser's cache and checked whether the web app runs in private mode but it still works.
I don't remember which Dockerfile
I used to run this container but this one is the closest:
FROM python:3.10
# EXPOSE 8050
WORKDIR /app
COPY . .
COPY models /app/models/
RUN pip install -r requirements.txt
EXPOSE 8050
CMD ["gunicorn", "-b", "0.0.0.0:8050", "--reload", "app:server"]
The image was probably built using:
docker build -f Dockerfile -t app:latest .
and run using:
docker run -p 80:8050 app:latest
This is the requirements.txt
file:
numpy
pandas
plotly
dash
gunicorn
dash-bootstrap-components
scikit-learn
xgboost
The app.py
file looks like this:
import time
import dash
import dash_bootstrap_components as dbc
import pickle
import numpy as np
import plotly.graph_objs as go
from dash import Input, Output, State, dcc, html
# import tensorflow as tf
# from tensorflow import keras
# from keras.models import load_model
#import xgboost
import re
app = dash.Dash(external_stylesheets=[
dbc.themes.COSMO])
# Include the server option to become able to deploy online
server = app.server
# Code for the app
if __name__ == "__main__":
app.run_server(debug=True, host="0.0.0.0",port="8050", use_reloader=True)
#app.run_server(debug=True)
The command docker --version
returns:
Docker version 20.10.24, build 297e128
Edit: I think that the image was actually run using the restart always
command:
docker run --restart always -p 80:8050 app:latest