I have python application which I am deploying through. Container is creating properly and it is up and running. But server is getting stop and throwing error.
Dockerfile
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"]
Error I am getting in the logs
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
Can someone please explain if there is any issue with dockerfile or the CMD command that I have define.
First attempt to update host to 0.0.0.0 but doesn't work.
Error:
[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
Binding to '0.0.0.0' (all NICs) seemed to solve the issue after hardcoding that to the app.start
function.
Before used to bind to ipv6 localhost address (::1
)