A browser on the Docker host reaches the web service at its published address. A second container in the project has a different route. Compose normally connects services in the same project to a shared network, where they can look each other up by service name.
Docker Compose · Lesson 3
Service Discovery
Learn how Compose services reach each other by name and how host access uses a published port.