Port mapping isn't working

While I am trying to follow the lecture of docker for beginners i tried to run a jekins container on my VM and map it to port 8080 so that i can access it on my windows machine hosting the VM. But i want try this on my browser http://<vm_ip>:8080.
I tried to check everything but the problem is persisting.

Have you used the -p argument to map the port from Docker’s virtual to your Windows box? This would be something like

docker run -p 8080:8080 -d --name jenkins jenkins

where :8080 is the original port assignment of the jenkins container, and the first 8080 is the port assignment on Windows.

1 Like

yes i specified that . i used this exact command:
docker run -p 8080:8080 jenkins/jenkins
when i did this i already checked that i have bridge adapter on the networks settings of the my ubuntu VM and that the port 8080 is free. it works perfectly fine on my VM but this isn’t the case for my windows machine (hosting the VM).
I even created an inboud rule in windows defender firewall to allow incoming traffic on that port . Even though i can ping the vm from host machine and vice versa this command curl http://<vm_ip>:8080 doesn’t seem to work with all those things i checked.

Have you tried http://127.0.0.1:8080? If I understand the docs for DDfW, this is the way they tend to map these things.

yes i tried it on my vm and it worked perfectly fine .

What I mean here is that DDfW likes to map port-fowards on Windows to that address as well. So I’d expect that you can browse http://127.0.0.1:8080 on your browser and it will work as well

i got you. but it doesn’t work

use -d in your command so that container stay running in background