I have two containers: one for Cypress and another for my web app. I have them both set up in a docker-compose.yml file like so:
version: '3.2'
services:
pa-portal:
image: web_app_image
container_name: pa_portal
volumes:
- productDB:/web_app/db
ports:
- "8080:8080"
cypress:
image: "cypress/included:4.4.0"
depends_on:
- pa-portal
environment:
- CYPRESS_baseUrl=http://pa-portal:8080
working_dir: /cypress-testing
volumes:
- ./:/cypress-testing
volumes:
productDB:
From the Cypress (testing framework) container I am able to access the web app using http://pa-portal:8080 but from a browser on my host the only way I can access the web app that has been launched by the pa_portal container is using localhost:8080.
Why are there different urls depending on where I am accessing from?
Is there some fundamental knowledge i need to do some research on
/etc/hostsand/etc/resolv.conf). Then you need to understand how Docker service discovery works.