如何使用Docker使用redis配置spring boot web app

如何使用Docker使用redis配置spring boot web app,docker,redis,spring-boot,docker-compose,Docker,Redis,Spring Boot,Docker Compose,我有一个小型spring boot web应用程序,它将数据保存到redis 运行docker-compose.yml后,容器被启动,但在localhost:8085i上出现“连接被重置” 弹簧靴应用程序.yml docker-compose.yml 如何链接spring boot和redis 我错过了什么?127.0.0.1是错误的地址。使用redis作为主机名。你说得对。我不能在docker和redis中使用地址127.0.0.1作为主机名。 server: address: 127

我有一个小型spring boot web应用程序,它将数据保存到redis

运行docker-compose.yml后,容器被启动,但在
localhost:8085
i上出现“连接被重置”

弹簧靴应用程序.yml docker-compose.yml 如何链接spring boot和redis


我错过了什么?

127.0.0.1
是错误的地址。使用
redis
作为主机名。

你说得对。我不能在docker和redis中使用地址127.0.0.1作为主机名。
server:
    address: 127.0.0.1
---
spring:
    profiles: development
server:
    address: 127.0.0.1
---
spring:
    profiles: production
server:
    address: 127.0.0.1
web:
  build: docker_app
  ports:
   - "8085:8080"
  links:
   - redis

redis:  
    image: redis