I'm having an issue running docker compose. Specifically i'm getting this error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.login-service.environment contains {"REDIS_HOST": "redis-server"}, which is an invalid type, it should be a string
And here's my yml file:
version: '3'
services:
redis:
image: redis
ports:
- 6379:6379
networks:
- my-network
login-service:
tty: true
build: .
volumes:
- ./:/usr/src/app
ports:
- 3001:3001
depends_on:
- redis
networks:
- my-network
environment:
- REDIS_HOST: redis
command: bash -c "./wait-for-it.sh redis:6379 -- npm install && npm run dev"
networks:
my-network:
Clearly the issue is where I set my environment variable even though i've seen multiple tutorials that use the same syntax. The purpose of it is to set REDIS_HOST
to whatever ip address docker assigns to Redis when building the image. Any insights what I may need to change to get this working?
-
to fix the syntax error. That is,environment
either expects a list ofkey=value
, or is a dict ofkey: value
. – Pibrochenvironment
here at all, if you are inside login-service container and you will doping redis
it will redirect to current IP of the redis, how is theREDIS_HOST
variable handled inside the login-service container? – Fetterlock