Can we have multiple ports exposed in a same container - Ex: Apache listening on 80, tomcat on 8080, wildfly on 8082?
Sure. But exposed posts are just documentation hints, they do nothing on their own.
They express the intention of the image maintainer which container ports should be published to host ports to access the application(s). Some management tools use exposed ports to pre-populate the container port for port mappings when a new container is created based on that image. By default, (aka when using a bridge network) the container will not be reachable from the host, unless the container port is published to a host port.
Hello,
Yes, you can expose multiple ports from the same Docker container. Use the EXPOSE instruction in your Dockerfile to specify which ports should be exposed within the container. When running the container with docker run, use the publish option to map these exposed container ports to specific ports on the host machine. For example, you can expose ports like 80, 8080, and 8082 simultaneously, allowing each service to be accessed through its respective port on the host.