Docker port gotcha
Just a very short hint, when running docker, be advised that the -p parameter must be before your -t parameter. Found out the hard way, after I couldn’t understand why my docker instance wasn’t available on localhost after I ran the command :
docker run -t app -p 9000:9000
Docker instance spins up fine, but there was no connection to the container when accessing http://localhost:9000.
after doing a docker inspect I could see that the port wasn’t bound, and after a while of searching for problems on the net, I just changed the command line to :
docker run -p 9000:9000 -t app
And there you are. Everything works fine, and I am able to connect to the docker container using http://localhost:9000.
So just a small hint.
-p option has to be before -t.
Doesn’t really make sense but there you are.
What really gave it away was when inspecting the processes, using dockerĀ ps I could see that the port section didn’t include 0.0.0.0
So if you have trouble not being able to reach your docker application, this might just be it
Leave a Reply