Python 通过 Docker 部署的应用程序出现错误
Python application giving error deployed through Docker
我有 python 正在部署的应用程序。容器正在正确创建并且已启动 运行。但是服务器正在停止并抛出错误。
Docker 文件
FROM python:3.8
# set the working directory in the container
WORKDIR /usr/src/app
# copy the dependencies file to the working directory
COPY requirements.txt ./
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY . .
EXPOSE 8000
# command to run on container start
CMD ["python3", "apps/main.py", "start", "--config", "config.yml"]
我进入日志时出错
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sanic/server.py", line 556, in serve
http_server = loop.run_until_complete(server_coroutine)
File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1775, in create_server
OSError: [Errno 99] error while attempting to bind on address ('::1', 8000, 0, 0): cannot assign requested address
[2021-09-17 12:50:51 +0000] [97] [INFO] Server Stopped
谁能解释一下我定义的 dockerfile 或 CMD 命令是否有任何问题。
第一次尝试将主机更新到 0.0.0.0 但没有成功。
错误:
[2021-09-17 15:02:24 +0000] [98] [INFO] Goin' Fast @ http://localhost:8000
[2021-09-17 15:02:24 +0000] [98] [DEBUG] Sanic auto-reload: enabled
[2021-09-17 15:02:24 +0000] [98] [DEBUG] Sanic debug mode: enabled
[2021-09-17 15:02:24 +0000] [98] [ERROR] Unable to start server
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sanic/server.py", line 556, in serve
http_server = loop.run_until_complete(server_coroutine)
File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1775, in create_server
OSError: [Errno 99] error while attempting to bind on address ('::1', 8000, 0, 0): cannot assign requested address
[2021-09-17 15:02:24 +0000] [98] [INFO] Server Stopped
绑定到“0.0.0.0”(所有 NIC)似乎解决了将其硬编码到 app.start
函数后的问题。
之前用于绑定到 ipv6 本地主机地址 (::1
)
我有 python 正在部署的应用程序。容器正在正确创建并且已启动 运行。但是服务器正在停止并抛出错误。
Docker 文件
FROM python:3.8
# set the working directory in the container
WORKDIR /usr/src/app
# copy the dependencies file to the working directory
COPY requirements.txt ./
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY . .
EXPOSE 8000
# command to run on container start
CMD ["python3", "apps/main.py", "start", "--config", "config.yml"]
我进入日志时出错
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sanic/server.py", line 556, in serve
http_server = loop.run_until_complete(server_coroutine)
File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1775, in create_server
OSError: [Errno 99] error while attempting to bind on address ('::1', 8000, 0, 0): cannot assign requested address
[2021-09-17 12:50:51 +0000] [97] [INFO] Server Stopped
谁能解释一下我定义的 dockerfile 或 CMD 命令是否有任何问题。
第一次尝试将主机更新到 0.0.0.0 但没有成功。
错误:
[2021-09-17 15:02:24 +0000] [98] [INFO] Goin' Fast @ http://localhost:8000
[2021-09-17 15:02:24 +0000] [98] [DEBUG] Sanic auto-reload: enabled
[2021-09-17 15:02:24 +0000] [98] [DEBUG] Sanic debug mode: enabled
[2021-09-17 15:02:24 +0000] [98] [ERROR] Unable to start server
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/sanic/server.py", line 556, in serve
http_server = loop.run_until_complete(server_coroutine)
File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1775, in create_server
OSError: [Errno 99] error while attempting to bind on address ('::1', 8000, 0, 0): cannot assign requested address
[2021-09-17 15:02:24 +0000] [98] [INFO] Server Stopped
绑定到“0.0.0.0”(所有 NIC)似乎解决了将其硬编码到 app.start
函数后的问题。
之前用于绑定到 ipv6 本地主机地址 (::1
)