Hi currently I’m playing around with docker and have sort of an understanding issue.
I have a web application which would basically need two containers one for tomcat and one for postgresql. As far as I understand I could either link them directly together or expose the ports so they could talk to each other right?
Now the most of the existing docker containers expose the standard port to the host (like official postgresql image). That would be fine if I only run one instance of my application on the host.
But I want to run multiple versions of my applications on my host system.
As far as I understand that would not work if I’m using images that already EXPOSEs the default ports. Is that right or do I have an understanding issue here?
So I would have to create my own images and use the link functionality to achieve this?
Basically I want to provide a server where a developer can startup easily a new instance of our web application to test something or present a demo.
EXPOSE does not map the port to the host system, it only indicates that these are ports that the container will listen to.
then you can --link containers together so they use those ports - without the host’s ports getting used at all.
The only time the container ports are actually mapped to the host ports, is if you use the
-p options - which in most of these cases you would not need.
I see. So EXPOSE should be used with the link option, -P/ -p to actually bind ports to the host. Got it! Thx!
Just got started with Docker. I have problem in running container with multiple applications and postgres installed.
I have installed Docker on CentOS 6.6, created a container and then installed postgres, two more applications using ports like 8444, 8443, 8089. I have committed the container changes and then created new image.
Trying to run a container using the new image is failing when I use -p switch, it says failed to start container.
- Once I install applications in the container, how to expose the ports so that next time when I run the container, I can map these to ports on host.
- Any issues with -p switch on centos/docker ?