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.

  • Editing a running docker container
  • Running MariaDB in a docker container using docker stack
  • Automated build with docker-compose (Application+mySQL server)
  • ImportError: No module named … on docker toolbar on windows
  • How to auto start docker when synology restart
  • What's the right way to setup a development environment on OS X with Docker?
  • Any idea whats happening here?

  • Can I run Docker in a Virtual Machine?
  • Kubernetes container connection to RDS instance in separate VPC
  • Is there a good reason for setting up virtualenv for python in Docker containers?
  • Django rest project dockerfile
  • Docker in docker on AWS Elastic Beanstalk
  • Docker ports work in localhost but not with public ip
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.