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.

  • Want to run docker in windows server 2016 on azure
  • Docker swarm - log to rsyslog container
  • How to view docker-compose healthcheck logs?
  • war-file as a part of container or shared folder when running docker
  • How to edit files in stopped/not starting docker container
  • How to query Docker DNS from within a container?
  • Any idea whats happening here?

  • Sending sigstop and sigcont to docker containers
  • Volume mapped filebeat.yml permissions from Docker on a Windows host
  • Docker container with Angular2 app and NodeJs does not respond
  • Linux Namespaces: Is it possible for a network namespace to exist without being associated with a process?
  • docker push - access not authorized
  • How do I obtain a nodes IP address in a swarm using docker remote API?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.