Gateway Timeout when using different port mapping

This may not be true in your case but in general with containers, I would not rely on ping at all. Ping uses ICMP low level protocol which has nothing to do with HTTP (I think it's not even TCP). You can have a successful ping but not HTTP server on an address and you can have an HTTP server that would not respond to ping. Also with containers, often a virtual network layer is used, for example in kubernetes pinging certain addresses that you can connect over HTTP is not possible in principle since they are not real IP address and traffic for them are not routed, in the sense that the IP address never appears in an IP packet header.. When you connect to them via HTTP though the virtual IP address get transparently substituted for a corresponding real one. So in general I would not trust a lot to ping as a diagnostic tool when you are trying to troubleshoot containerized web applications.