Why aren't you using a single docker-compose.yml file?
Nov 29, 2021
1
Level 1
Docker how to use service name in .env file?
I have 2 Docker containers spawned from 2 different docker-composer.yml files;
-
container-1(Laradock container with Laravel app) -
container-2(container with rest api)
I linked them both in the same network, but in my Laravel .env inside container-1, if I try and reference a service inside container-2 as a host var (to send requests to the API), it doesn't work.
I checked with docker network inspect my_network and confirmed that container-1 and container-2 are both connected to it, but when I try and make requests the host env doesn't get swapped out so it just ends up calling <env>:443
Any docker experts here who can help me with solving this? Thanks!
Please or to participate in this conversation.