Why would you use the server IP instead of “localhost” if both processes are inside the same container? If the processes are in two different containers, you can use the MySQL container’s name as hostname to connect to the database. MySQL shouldn’t even listen on a LAN IP and you should not forward ports from the LAN IP to the container unless it is a database server and you want to connect to the database from other hosts…
No, the correct way would be using the service names as I mentioned in my previous comment.
That is not likely to be blocked, but that could happen too in case of an incorrectly configured firewall.
What do you mean by “some suers end up using the ip”? The point is not using a hostname but to use internal ip addresses instead of the ip of the host. The service name/container name points to an internal ip address in a Docker network.