how to connect the eureka server and eureka client using different docker-compose files

How can I connect the eureka server and eureka client using docker compose? I have simple client with application.yml where configured the configurations for connection to eureka server:

spring:
  jackson:
    serialization:
      fail-on-empty-beans: false
  application:
    name: usersMicro
  jpa:
    show-sql: true
    database: POSTGRESQL
    hibernate:
      ddl-auto: create-drop
  datasource:
    url: jdbc:postgresql://localhost:5432/my_test_db
    username: root
    password: admin
    driver-class-name: org.postgresql.Driver
server:
  port: 8089
#eureka:
#  client:
#    serviceURL:
#      defaultZone: http://localhost:8761/eureka/

eureka:
  client:
    serviceURL:
      defaultZone: http://localhost:8761/eureka/
    service-url:
      zone1: http://localhost:8761/eureka/
    region: region-1
    availability-zones:
      region-1: zone1

the standard eureka client Dockerfile:

    FROM ubuntu:latest
    LABEL authors="user"
    
    ENTRYPOINT ["top", "-b"]
    
    FROM openjdk:17-jdk-slim
    VOLUME /tmp
    COPY target/usersMicro-1.jar user-service.jar
    ENTRYPOINT ["java","-jar","/user-service.jar"]

and docker-compose.yml file:

version: "3.9"
services:
  user-service:
    container_name: user-service
    image: user-service
    restart: unless-stopped
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8089:8089"
    networks:
      - postgres
networks:
  postgres:
    name: shared-network
    external: true

The eureka server is almost the same
the server eureka application.yml is:

spring:
  application:
    name: eureka_server
server:
  port:
    - "8761:8761"

eureka:
  hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false

eureka server Dockerfile is the same, except lines

    COPY target/eureka_server-1.jar eureka-server.jar
    ENTRYPOINT ["java","-jar","/eureka-server.jar"]

and eureka server docker-compose.yml file:

version: '3.9'
services:
  # EUREKA-SERVER CONTAINER............................................
  eureka_server-service:
    container_name: eureka_server
    image: eureka_server
    restart: on-failure
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8761:8761"
    networks:
      - postgres
# NETWORKS CONFIGURATION....................................................
networks:
  postgres:
    name: shared-network
    external: true

My docker-compose files for server and client are in different directories and may be that is the problem, that they should be specified in the same file, but I was able to connect my microservices with DB which is in a strict different drive.

If I start the server and client out of docker, from IDE, I am able to see the connection in eureka web interface, but if docker – in logs, I receive the error that connection refused:
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server or 2024-08-06T13:28:24.835500447Z Caused by: org.apache.hc.client5.http.HttpHostConnectException: Connect to http://localhost:8761 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused

what I miss in these configurations ?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật