Docker Community Forums

Share and learn in the Docker community.

Connect two services but from different stacks


(Mikedavem) #1

Hi all,

I’m trying to understand how to connect a service to another service which is in a different stack (on a Docker swarm architecture) My collectd service must connect to a SQL Server instance DB (db service in a different stack dbi). Here the sample of my docker-compose file.

version: '3'

services:
 collectd:
    image: microsoft/mssql-monitoring-collectd:latest
    environment:
      - INFLUX_DB_SERVER=influx
      - INFLUX_DB_PORT=25826
      - SQL_HOSTNAME=db.dbi
      - SQL_USERNAME=sa
      - SQL_PASSWORD=Password1
      - SQL_POLL_INTERVAL=5
    networks:
      - back-tier
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager

From my understanding we need to provide something like that <service_name>.<stack_name>.
So is it correct if the SQL_HOSTNAME environment variable value is confgured as follows: SQL_HOSTNAME=db.dbi as show above.? My tests failed so far.

Thanks for your feedback