昨天,我发现我的机器(MacOS蒙特雷)上仍有一个容器在运行.我在StackOverflow上搜索我的问题的答案,但我try 的任何东西都不起作用.

我先做了docker ps,然后做了docker stop <container-ID>,但Web应用程序仍在端口0.0.0.0:80上运行.

我不记得我是什么时候运行这个容器的,但它是在开发Dash Ploly应用程序时运行的.

在上述try 失败后,我try 了:

docker system prune --all --force --volumes

它从我的系统中删除了所有容器和图像(它确实起作用了,因为图像确实从我的Docker Desktop列表中消失了).

然后我重新启动了电脑,但Web应用程序仍然在那里.

然后,我运行命令:

sudo lsof -i -P -n | grep 80

这给出了我的输出:

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)

我试着终止这些进程,看看有没有办法,sudo kill -9 <PID>,但也没有效果.

最后,我清理了浏览器的缓存,并判断了Web应用程序是否在私密模式下运行,但它仍然可以运行.

我不记得我用哪个Dockerfile来运行这个容器,但这个是最接近的:

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"]

该映像可能是使用以下工具构建的:

docker build -f Dockerfile -t app:latest .

并使用以下工具运行:

docker run -p 80:8050 app:latest 

这是requirements.txt号文件:

numpy 
pandas 
plotly 
dash 
gunicorn  
dash-bootstrap-components
scikit-learn 
xgboost

app.py文件如下所示:

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)

命令docker --version返回:

Docker version 20.10.24, build 297e128

编辑:我认为该映像实际上是使用restart always命令运行的:

docker run --restart always -p 80:8050 app:latest

推荐答案

经过大量的搜索,我首先发现了导致问题的服务是Apachehttpd服务器.我使用以下命令列出了在端口80上运行的所有服务:

sudo lsof -i :80

try 使用以下命令终止该进程

sudo kill -9 <process_id>

未执行任何操作,同时使用

sudo pkill httpd

停止Web服务几秒钟,但随后它又回来了.我能够使用以下命令停止服务器:

sudo apachectl stop

为了防止它重新启动,我编辑了文件/etc/apache2/httpd.conf,并特别注释掉了这一行:

#LoadModule mpm_prefork_module

在完成所有这些操作之前,我卸载并重新安装了Docker,但这并没有起到任何作用.

Python相关问答推荐

将C struct 的指针传递给Python中的ioctel

调试回归无法解决我的问题

FastAPI:使用APIRouter路由子模块功能

如何让pyparparsing匹配1天或2天,但1天和2天失败?

替换字符串中的点/逗号,以便可以将其转换为浮动

将行从一个DF添加到另一个DF

对整个 pyramid 进行分组与对 pyramid 列子集进行分组

如果值不存在,列表理解返回列表

管道冻结和管道卸载

如何在UserSerializer中添加显式字段?

在单个对象中解析多个Python数据帧

使用Python从URL下载Excel文件

UNIQUE约束失败:customuser. username

Python列表不会在条件while循环中正确随机化'

将pandas导出到CSV数据,但在此之前,将日期按最小到最大排序

CommandeError:模块numba没有属性generated_jit''''

解决调用嵌入式函数的XSLT中表达式的语法移位/归约冲突

如何在两列上groupBy,并使用pyspark计算每个分组列的平均总价值

为什么常规操作不以其就地对应操作为基础?

在Docker容器(Alpine)上运行的Python应用程序中读取. accdb数据库