Change database host

I've been struggling with this setting for a long time and I realized if I changed the DB_HOST to wordpress_db_1 (which is container name) from db, it worked. Is it something I've done wrongly or is it a mistake on this document?