Let's say I have 2 services defined in my docker-compose.yml
like that
# Service app
app:
networks:
- backend
# Service server
server:
networks:
- backend
ports:
- 80:80
The app
service will upload data on the server
service by requesting http://server:80/
and it will display the data url http://server:80/data
Now from my browser I want to click that link but I can't access the server
via it's docker hostname, I can only access it via http://localhost:80/data
.
Is there anyway to configure my docker-compose
to map the hostname server
outside of docker so it's accessible from my host machine ?
No.
You will have to update your hosts file /etc/hosts
(C:\Windows\System32\Drivers\etc\hosts
on Windows) with an entry similar to below:
127.0.0.1 localhost server