I’m new to Docker. I’m build a Spring Boot Application deploying on Docker.
Here is my example docker-compose,
version: "3" services: user: container_name: user image: user-service build: context: user-api/ ports: - "3001:8000" restart: always volumes: - /home/ubuntu/logs/user_service:/opt/app/logs networks: - api_network cms: container_name: cms image:cms-service build: context: cms-service/ ports: - "3003:8000" restart: always volumes: - /home/ubuntu/logs/cms_service:/opt/app/logs networks: - api_network networks: api_network: driver: bridge
In the server machine, there’s a Redis Server running on Ubuntu. I cannot connect the the Redis Server from Docker container to the host machine.
Here is my redis config inside application.properties
spring.redis.host=localhost spring.redis.port=6379 [email protected]#
I also tried to change the localhost to
That’s I’ve found on the internet. But nothing works. Do I need to specifically config anything to allow my Spring Boot Service inside Docker connect to Redis that’s running on localhost.
Thanks a lot.
Source: Docker Questions