'Connection refused (Connection refused) between containers | ifnazar / docker-sybase

I have two containers in my docker-compose and my node application does not connect to Sybase database but my local machine connects

version: '3'

services:
  api-sybase:
    build: .docker/api
    entrypoint: .docker/entrypoint.sh
    container_name: api-sybase
    volumes:
      - .:/home/bmg/api
    ports:
      - "3000:3000"
      - "9229:9229"
    tty: true
    networks:
      - nestjs-network
    depends_on:
      - sybase
    restart: unless-stopped
    
  sybase:
    container_name: sybase
    image: ifnazar/sybase_15_7
    stdin_open: true
    tty: true
    hostname: dksybase
    build: .docker/sybase
    command: bash /sybase/start
    ports:
      - "5000:5000"
    expose:
      - "5000"
    environment: 
      - SYBASE_DB=bmg-teste
    networks:
      - nestjs-network
    restart: unless-stopped

networks:
  nestjs-network:

Output error:

Error: java.sql.SQLException: JZ006: Caught IOException: java.net.ConnectException: Connection refused (Connection refused) JZ006: Caught IOException: java.net.ConnectException: Connection refused (Connection refused)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source