Tried looking around but couldn't find anything close to what I need.
I have a docker-compose file with a docker container (web
) that uses another container's IP (api
) in its environment variable by resolving the hostname:
version: '3'
services:
web:
build: ../client/
ports:
- "5000:5000"
- "3000:3000"
environment:
REACT_APP_API_DEV: http://api:8000/server/graphql
api:
build: ../server/
env_file:
- server_variables.env
ports:
- "8000:8000"
redis:
image: "redis:alpine"
My issue is that web
doesn't resolve this variable when it's running. I can ping api
just fine inside the web
container but http://api:8000
doesn't resolve properly. I also tried making HOST=api the variable and building the URI manually but that doesn't work either.
EDIT: I added a complete docker-compose.yml file for reference. I can curl
the api
just fine from inside the web
container, but my app can't seem to resolve it properly. I'm using NodeJS and React