Access running jenkins container

Hello friends,

i was following the docker lectures, specifically demo-advanced-docker-run-features. I ran jenkins container on my mac computer and tried to access http://172.17.0.2:8080/ but i got This site can’t be reached page.

However, when i run jenkins container from an ubuntu VM on my mac, i was able to access http://172.17.0.2:8080/ successfully from Mozilla firefox.

Can someone please explain why the difference and what is going on. I don’t seem to understand this part of the lecture. Help please :pray:

If you are running it in docker, you have to port forward from the host machine (your computer running docker) into the container. The host machine cannot directly access the container network

docker run jenkins -d -p 8080:8080

The -p argument creates a port forward from your machine on 8080 to the container on 8080.

You should then be able to access on http://localhost:8080 from the browser.

Thanks for the reply, sorry I was not clear with my question but the puzzling question is why was I able to access the Jenkins UI from Ubuntu without creating a port forwarding

With the VM, it depends on how you configured networking to the VM in the VM manager (virtualbox?). It is possible to set it up so that the VM’s virtual network can be seen directly from the host.
In docker, the virtual network isn’t directly accessible from the host.
However, if you run a container with docker run --network host then the container appears on the host network and can be accessed directly. This works on Linux, might work on Mac and probably not on Windows