I am connecting to Redis from the spring boot app on the outside machine where the Redis server docker container is not ruSo wheng. When the app tries to connect to Redis, the app can't cappropriatelyroperly until the sent request is timed out. Meanwhile, if I try to connect from:
application.properties:
spring.redis.host=pc-1
spring.redis.port=6379
pc-1
is alias from some numerical ip. I'am using hosts feature from windows to aliasing/redirecting it.
.env:
REDIS_PORT=6379
docker-compose.yml:
redis:
image: redis:latest
ports:
- "${REDIS_PORT}:6379"
command:
# - redis-server
# - --requirepass "${REDIS_PASSWORD}"
networks:
- redis
healthcheck:
test: ["CMD-SHELL", "redis-cli ping"]
interval: 10s
timeout: 10s
retries: 3
I need help on this issue.
Use the --service-ports
flag to the docker compose command to publish the ports you've defined in the docker compose file.
Other debugging tips:
${REDIS_PORT}
variable in case the value is not getting set or set a default like ${REDIS_PORT:-default}
docker compose --env-file./somedir/.env up
in case the env file is not being pick up
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.