I was following the docker lectures, specifically demo-advanced-docker-run-features. I ran jenkins container on my wsl and tried to access (http://172.17.0.2:8080/ )but i got “This site can’t be reached” page. But I could able to access http://localhost:8080/
docker run -d --name jenkinstest -p 8080:8080 jenkins/jenkins
This is expected behaviour. Docker containers, by default, run in their own isolated network.
When you run a container, Docker assigns it an IP address in this private network (like 172.17.0.2 in your case). This IP address is only reachable from within the Docker host, not from your local network or the internet. So that is why you need to forward the port (-p) to access Jenkins.