I am running spring boot config server in a Docker container locally. with below configuration in docker-compose.yml but its failing to connect with gitlab server
networks:
private-net:
ipam:
driver: default
config:
- subnet: 192.168.0.0/16
public-net:
ipam:
driver: default
config:
- subnet: 172.16.0.0/16
services:
test-config-server:
image: ${DOCKER_REGISTRY_ROOT}/com/rohila/api/vcp/test-config-server:develop
networks:
- private-net
ports:
- "8888:8888"
I am getting below error in logs
Caused by: java.net.UnknownHostException: gitlab.com: Temporary failure in name resolution
2024-05-11 09:33:32 at java.base/java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:934) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1543) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1533) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1385) ~[na:na]
2024-05-11 09:33:32 at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1306) ~[na:na]
I have tried to remove networks , ihave tried adding public network and both public and private but its still not working could you please advise how can i fix it?
It seems like the issue is with resolving the hostname "gitlab.com" within your Docker container where your Spring Boot config server is running. This error usually occurs due to a DNS resolution problem.
Ensure that the Docker container running your Spring Boot config server has proper DNS configuration. You can check this by running the following command inside your container.
cat /etc/resolv.conf
(It should point to a valid DNS server. If not, you may need to update Docker's DNS settings)
You can try using the same DNS server that your host machine is using by adding the DNS server configuration in your docker-compose.yml file.
services: test-config-server: dns: - 8.8.8.8 image: ${DOCKER_REGISTRY_ROOT}/com/rohila/api/vcp/test-config-server:develop networks: - private-net ports: - "8888:8888" Sometimes, restarting the Docker service can resolve DNS-related issues. You can try restarting Docker after making the necessary changes.