I have a docker container running where I a have mapped 8090 port of host to 8080 port of docker container (running a tomcat server). Is there any way by which I can get the mapped port information from container?
i.e. is there any way by which I can get to know about 8090:8080 mapping from container?
When you link containers, docker sets environment variables which you can use inside one docker to tell how you can communicate with another docker. You can manually do something similar to let your docker know about the host's mapping:
explanation:
export HOST_8080=8090
defines an environment variable on your host (so you won't have to write the "8090" thing twice).-p $HOST_8080:8080
maps the 8090 port on the host to 8080 on the docker.-e "HOST_8080=$HOST_8080"
defines an environment variable inside the docker, which is called HOST_8080, with value 8090./bin/bash -c export
just prints the environment variables so you can see this is actually working. Replace this with your docker's CMD.