Score:0

Unable to forwart ports on any docker

je flag

So I was trying to set up some websites and other stuff on my Ubuntu 20.04.3 LTS Server. Different WebUI bases apps in different dockers accesed via a nginx. But I want able to connect to ANY of my dockers. After trubble shooting it seems that the port forwarding doesnt work on none of my dockers. It started with my node-red docker, nginx didnt work either and I now have setup a very simple whoami docker wis a very basic webserver running on port 8000. I'm still not able to connect to it.

If I go into the docker using an "docker exec -ti whoami sh" I am able to access the webserver via wget but not from outside the docker.

I have searched a lot and most issues where false use of the -p flag or the webserver only listening to localhost and so on. Both is not the case here.

Here is my test terminal output to show whats happening

$~ docker ps
CONTAINER ID   IMAGE            COMMAND       CREATED              STATUS              PORTS                                       NAMES
726da9705b7f   jwilder/whoami   "/app/http"   About a minute ago   Up About a minute   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   whoami
$~ 
$~ wget -O - http://127.0.0.1:8000/
--2021-10-16 23:19:09--  http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

--2021-10-16 23:21:21--  (try: 2)  http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... connected.
HTTP request sent, awaiting response... ^C
$~ 
$~ docker exec -ti whoami sh
/app # wget -O - http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000 (127.0.0.1:8000)
I'm 726da9705b7f
-                    100% |*****************************************************|    17   0:00:00 ETA
/app # exit
$~ 
$~ cat run.sh
docker run -d -p 8000:8000 --name whoami -t jwilder/whoami
$~ 
$~ 

Proof that the server is not fixed to local host:

$~ 
$~ docker logs -f whoami
Listening on :8000
I'm 726da9705b7f
^C
$~ 
$~ docker exec -ti whoami sh
/app # ./http
Listening on :8000
2021/10/16 22:36:23 listen tcp :8000: bind: address already in use
/app # exit
$~ 
$~ 

And as far as I can tell the docker service actualy take the port:

$~ 
$~ sudo lsof -i:8000
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 24976 root    4u  IPv4 112329      0t0  TCP *:8000 (LISTEN)
docker-pr 24984 root    4u  IPv6 114001      0t0  TCP *:8000 (LISTEN)
$~ 
$~ 

But its still not working.

Does anybody has an idea what is going wrong I am very clueless.

Phillip avatar
je flag
Ok I mean while found out that if I purge and reinstall docker.io the first time I use a port works but if I stop and rm the docker and use docker run to recreate it, it stops working.
Score:0
de flag

Try to run this container on a different port:

$ docker run --rm -d -p 8001:8000 --name whoami -t jwilder/whoami
64a5059666e0f3db12562a44edf576336f73fcecd5e7d86c1e739259e1ffd307
$ curl localhost:8001
I'm 6a82c9e7371e

If this works, then it might be something fishy happening on the host (maybe iptables with port redirection).

Phillip avatar
je flag
Nope doesn't work.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.