Connection reset when connecting to container

HI,
i am trying to setup a jupyter container on a server and access it via another device in the network.
the image used is this https://hub.docker.com/r/jupyter/datascience-notebook
the server is running ubuntu

no matter what option i use, the ip given was always http://127.0.0.1:8888/lab?token=xxxxxx
i tried connecting using server-ip:8888 or the port i set via -p but the response is always connection reset

And how did you start the container exactly? Unless you forward a port to the container from the host, the loopback IP will not work as each container has its own network namespace.

i used docker run -p 888:888 jupyter/datascience-notebook
sry, new here, what do you mean by loopback IP will not work? i tried connecting with the server’s IP its still getting resetted

127.0.0.1 is a special IP, it is every computer‘s localhost. It can just be used locally, you can’t access another machine with it.

Usually every computer will have another IP, which it gets assigned from the local router or manually, by which it can be reached over the local network.

yes, i understand but even with cmd like -p (ip of server):111:111,
the link given still says 127.0.0.1:8888 and if i try to reach the server on (server ip):111, i still get a connection reset error.
thinking about it, could it be an issue with the image’s CMD that fixed the ip and port?

Sometimes it helps to RTFM (doc):

Since 2023-10-20 our images are only pushed to Quay.io registry. Older images are available on Docker Hub, but they will no longer be updated.

So to get a current image with latest features and bugfixes, you should use:

docker run -p 10000:8888 quay.io/jupyter/scipy-notebook:2024-10-07

A link like 127.0.0.1:8888 is valid on the same machine/PC. It is not valid to connect from another machine.

With -p 8888:8888 the Docker container will automatically listen on all available IPs of the machine, so you just need to find the right IP to connect over the network.

Are you using Docker Desktop or plain Docker?


hi, i used the exact same command and this error is still appearing

This is really a very basic Linux networking question, has nothing to do with Docker.

The app suggests using localhost or hostname, which might not be registered in local DNS.

Run ifconfig or ifstat on your server, assuming it is some kind of *nix, to find the host IP.

If it’s a public hosted server, you can also try curl 'https://api.ipify.org'.


this is the address of the server and the address i was trying to connect to.
my device is in the same network, i can reach it via ssh and ping it but if i try to connect to container running on it , the result is always connection reset or refused.
DNS shouldnt be an issue, as i was using IPs only

Maybe test with a different container/image:

docker run -d -p 11111:80 --name whoami traefik/whoami

and

curl http://172.20.140.30:11111


this is what i got

Can you access the whoami service on the server from the other machine?

no, still connection refused

What server OS are you using? How did you install Docker?

What network are you using? Private or corporate network? Any VLAN used? Firewalls?

What client OS are you using? Any special firewall installed?

In this example you just forward port 111 ( left side) from the host to the container IP on port 111 (right side). It won’t change what port the app is listening on. So you need to forward port 111 from the host to port 8888 in the container. Which you did after @bluepuma77 suggested it for the whomi container. The application in the container will not know your IP address on the host so it can’t show you that.

The only problem could be if the service inside the container actually listens only on localhost which would not make sense usually (sometimes it does)

You used the container port again, not the host port which is port 10000 on your screenshot.

If the host IP doesn’t work from another machne or probably even from the same machine, that could be a windows firewall issue and you need to allow the inbound port: How to open ports in Windows Firewall | Windows Central

But if the port mapping is correct, the 127.0.0.1 IP should work from the host using it with the host port defined on the left side of the colon in the docker run command.

I guess you just typed it wrong and the port was 8888 in both side. If not, that was pointing to a wrong container port.

ok i think things got messed up a bit, so here is the problem:
image
when this cmd is used, port 8888 on the host should be forwarding to port 8888 on the jupyter container
so if i connect to the server’s ip (172.20.140.30) on port 8888, i should be able to access the container


but no, the connection gets resetted
so, im kinda at a loss on what went wrong

the server is ubuntu 22.04, client is win11 only win defender
im using a VPN connecting to a private network, ill go try again tmr on site and see if anything change

Unless a Windows firewall forbids it. I never remember how it works on Windows without testing and I can’t test it now, so I linked the tutorial about that. Have you checked it?

There was also a bug: https://docs.docker.com/desktop/release-notes/#4351
which was fixed in v4.35.1. Port 8888 was previously used by Docker DEsktop, but that would have given you a different output, not the error message.