Reputation: 2795
I just started learning docker and got stuck here. So first I tried to run jenkins image and map a port so I can access it from my browser, but I didn't succeed. When I open localhost from browser at the specified port I get nothing. The same was with tomcat.
I run it like this: docker run -it --rm -p 8888:8080 tomcat
and I get output in cmd prompt like everything is setup like it should, but nothing appears in browser. And in docker ps
I can see that tomcat container is running on port 8888 like it should.
Upvotes: 0
Views: 359
Reputation: 2795
The problem was that I was checking the wrong IP. On localhost I wasn't able to access anything running in docker containers, but when I tried the address that is provided in cmd prompt every time when docker is started I got what I want.
Upvotes: 0
Reputation: 159
Here's a couple of steps you could follow to trace the issue:
Check if the service is running correctly inside the container
you can enter the container using:
docker exec -it [container id] bash [or ash depends on your image]
and then check if the container is running your desired service correctly running telnet could be useful here.
Or you could check the container logs. simply run on host:
docker logs [container id]
check if docker is correctly binding your ports
run on host :
sudo netstat -nlp | grep :8888
this should list that the dockerd 'docker daemon' is using the port
And if all of that went well then you should check your firewall rules as it could be preventing any connection on these ports
p.s. the --rm
option means that Docker will automatically clean up the container and remove the file system when the container exits. So there is no persistence whatsoever.
Hope this was useful.
Upvotes: 1