I'm trying to connect from a node app container to a postgresql container using docker-compose but I'm not able to do it.
This is my docker-compose.yml file:
version: '3.7' services: db: image: postgres:12.1 ports: - "5432:5432" env_file: - "./.env" networks: - tcp-modbus volumes: - ./modbustcp.sql:/docker-entrypoint-initdb.d/init.sql redis: image: redis:5.0.6 ports: - "6379:6379" networks: - tcp-modbus rabbit: image: "rabbitmq" environment: RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG" RABBITMQ_DEFAULT_USER: "*" RABBITMQ_DEFAULT_PASS: "*" RABBITMQ_DEFAULT_VHOST: "/" ports: - "15672:15672" - "5672:5672" volumes: - "./enabled_plugins:/etc/rabbitmq/enabled_plugins" networks: - tcp-modbus modbus-tcp: image: customImage ports: - "8080:3000" links: - "db" volumes: - "./modbus.env:/usr/src/app/.env" networks: - tcp-modbus networks: tcp-modbus: driver: bridge
version: '3.7'
services:
db:
image: postgres:12.1
ports:
- "5432:5432"
env_file:
- "./.env"
networks:
- tcp-modbus
volumes:
- ./modbustcp.sql:/docker-entrypoint-initdb.d/init.sql
redis:
image: redis:5.0.6
ports:
- "6379:6379"
networks:
- tcp-modbus
rabbit:
image: "rabbitmq"
environment:
RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG"
RABBITMQ_DEFAULT_USER: "*"
RABBITMQ_DEFAULT_PASS: "*"
RABBITMQ_DEFAULT_VHOST: "/"
ports:
- "15672:15672"
- "5672:5672"
volumes:
- "./enabled_plugins:/etc/rabbitmq/enabled_plugins"
networks:
- tcp-modbus
modbus-tcp:
image: customImage
ports:
- "8080:3000"
links:
- "db"
volumes:
- "./modbus.env:/usr/src/app/.env"
networks:
- tcp-modbus
networks:
tcp-modbus:
driver: bridge