Having this issue of connection reset by peer when doing a curl to to docker server. curl 127.0.0.1:8080
Also cannot access the server from browser, but docker status says: UP 4 hours ago How can one fix this?
tried the following commands and docker seems to work fine but becomes unaccessible after few minutes.
docker build -t abelakponine/dockerimage .
docker run -p 0:8080 -itd --name imagename abelakponine/dockerimage
docker ps -a
docker logs --follow dockerprocessId
Here's what my dockerfile looks like:
FROM python:3.11.6
COPY . /App
WORKDIR /App
ENV PYTHONUNBUFFERED=1
EXPOSE 8080
CMD apt -y update \
&& python3 --version \
&& hostname -I \
&& curl -4 icanhazip.com \
&& pip install -r requirements.txt \
&& pip install waitress gunicorn django-livereload-server whitenoise \
&& python3 manage.py runserver 0.0.0.0:8080
So to solve this issue is simple, after many trials I figured what the problem is.
First of all, the port mapping 0:8080 was set to a port that was not listening on the server, so I corrected this to 8080:8080
Secondly I added --network host to the run command, this tell the docker server to run on the host server
Note: Since we are adding --network host
there's no need for including -p 8080:8080
as this becomes redundant.
the complete code looks like this:
docker run --network host --name testimage -itd abelakponine/testimage
also do
docker logs --follow cointainerId
to view running docker logs
doing:
netstat -lnt
shows the running port: 127.0.0.1:8080