The meaning of life is to explore the world

Docker-compose port mapping

Posted on By Jason Liu

How to route network traffic from same port to different containers

How to route network traffic to different containers if only port 443 is allowed from external?
1. If there’s only one domain and one port, then reverse proxy may be necessary for URL based routing.
2. If we have different domains but same port, then we can either:\

  • Use port forwarding to redirect traffics to the docker host IP with different ports, mapped by docker compose file. -or-
  • Assign different IPs for the containers, e.g. - ports: 1.2.3.4:443:443 (IP:Host-port:Container-port)