docker -P not exposing ports of application started as argument

I’d like to start a container with an argument to start a server inside the container. The problem is the -P switch is not exposing the ports of this server to my host.

docker run -it -e "JAVA_HOME=/opt/jdk1.8.0_45" -e "CARBON_HOME=/opt/IOT/wso2iots-1.0.0-SNAPSHOT" -P ubuntupreped:2.0 /bin/sh /opt/IOT/wso2iots-1.0.0-SNAPSHOT/bin/

When I build a image exposing the env variables and a script to start the server, the -P switch works as expected.

  • Mongodb in Docker: numactl --interleave=all explanation
  • Docker - Not able to telnet Linked Container
  • Run Docker container with preset IP from Ansible
  • Using Docker Containers
  • Docker run/star/exec?
  • Why is Docker not adding files to my container?
  • Any idea whats happening here?

  • Run Eclim on the remote server
  • Setting up dnsmasq docker container for dns-caching
  • Which device Docker Container writing to?
  • Docker: Write Permission on directory, but user cannot write
  • Setting fixed address/network for docker0 bridge interface on Ubuntu
  • Cannot acces Asp.Net Core on local Docker Container
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.