Describe the bug So, I try to connect my spring app to the cloud config server, but it doesn't work when I try to access it after I deploy my app from inside the docker. ```version: "3.0" networks: vd-network:
services:
config:
image: hyness/spring-cloud-config-server:3.1.3-jdk11
deploy:
labels:
description: "Spring Cloud Config Server"
mode: replicated
restart_policy:
condition: on-failure
networks:
- vd-network
environment:
- SPRING_APPLICATION_NAME=config
- SERVER_PORT=8888
- SPRING_CLOUD_CONFIG_SERVER_GIT_URI=
bootstrap-docker.yaml
```spring:
application:
name: ${name:config}
cloud:
config:
failFast: true
name: ${name:config}
profile: ${profile:local}
debug: true
uri: ${config.host:http://config:8888}
label: main
config:
import: optional:configserver:${config.host:http://config:8888}
This doesnt work, and If I change it to localhost, it works only when deploying the app directly, but not when running through docker.
What is the reason for the inability to connect. when running through docker?
Comment From: ryanjbaxter
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Comment From: VMM-MMV
The problem was that they were not on the same network. Then after this, I had another problem of the app starting before the cloud config server and requesting the data from it, from an endpoint, but as it was not fully started, it failed. I fixed it by adding:
deploy:
restart_policy:
condition: on-failure
Now it fails repeatedly until the server starts and then it is able to connect. I have tried using healthcheck and conditionals, but the cloud server config image does not allow execution from terminal, I tried with wait-for-it.sh, with which I had some other problems. So, in the end I solved it with this. If you have a better solution, please let me know. So now my app looks something like:
my-app:
image: my-app-image
deploy:
mode: replicated
restart_policy:
condition: on-failure
depends_on:
- config
networks:
- vd-network
ports:
- "9000:9000"
Comment From: ryanjbaxter
Thanks for the update!
Comment From: VMM-MMV
No, problem. The less people have to do this, the better.