Why does Docker define invalid IP address of service?
Ok, I have found the reason:

I tested starting the services with different environment variables for db. And after that I shut the services down, changed the db name, username and password, and started the services again. 

But I forgot that db folder /var/lib/mysql is mounted in a volume, and it remembered my previous data; everything was mixed up. So it's not problem in network, it's mixed data in mysql (different passwords for the same user).