如何使用Docker配置带有Redis的Spring Boot Web App [英] How to configure spring boot web app with redis using Docker

查看:83
本文介绍了如何使用Docker配置带有Redis的Spring Boot Web App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型的spring boot Web应用程序,可将数据保存到redis。

I have a small spring boot web application which saves the data to redis.

运行docker-compose.yml容器后,启动容器但在 localhost:8085 我有连接已重置。

After running docker-compose.yml containers are started but on localhost:8085 i have "The connection was reset".

server:
    address: 127.0.0.1
---
spring:
    profiles: development
server:
    address: 127.0.0.1
---
spring:
    profiles: production
server:
    address: 127.0.0.1



docker-compose.yml



docker-compose.yml

web:
  build: docker_app
  ports:
   - "8085:8080"
  links:
   - redis

redis:  
    image: redis

如何链接spring boot和redis?

How do I link spring boot and redis?

我错过了什么?

推荐答案

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

127.0.0.1 is the wrong address. Use redis as the hostname.

这篇关于如何使用Docker配置带有Redis的Spring Boot Web App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆