Docker Compose aggiunge effettivamente i nomi host di tutti i contenitori collegati tra loro.
Sulla tua macchina, il database postgres è effettivamente in esecuzione in localhost, ecco perché hai il localhost nome host.
In Compose, è in esecuzione nel contenitore postgres, con il nome host postgres , ecco perché hai il postgres nome host.
Se lo desideri, puoi creare una voce nel tuo file host per reindirizzare postgres a localhost , dovrai solo usare postgres ovunque.