Docker Community Forums

Share and learn in the Docker community.

Invalid port container


(docker learner) #1

Hi I am trying to practise creating new application using
$ docker run -d -P training/webapp python app.py

but getting error as
docker: Invalid containerport: training

I am using MAC OS


(David Maze) #2

Are you sure it’s a capital “P”? (A lowercase “p” would probably cause that error…)


(docker learner) #3

yes, It is lowercase only when I am trying it on my sysytem but just typing mistake here


(David Maze) #4

If you’re typing a lowercase “-p”, that would cause your error. There’s two ways to cause Docker to expose a port:

  1. If you know what port the image exposes, and you want to pick your own port on the host, you can docker run -p 12345:8000 training/webapp ... (with a lowercase “-p”). That will cause whatever the container runs listening on port 8000 to appear at port 12345 on your host system.
  2. If you don’t know or you’re willing to let the Docker pick the port number for you, you can docker run -P training/webapp ... (with an uppercase “-P”). docker ps will tell you what port(s) it’s listening on.

In both cases, if it is a Web application, and you’ve found out it’s on host port 12345, then typing http://localhost:12345/ into your browser will take you to it.


(docker learner) #5

Thanks David, resolved the issue