title: how to connect to container in docker stack deploy
body: <p>I'm trying to use docker stack deploy to deploy a node app. This should be obvious I guess, but how do I connect to the database from the node app?</p>
  
  <p>This is my sample docker file - I haven't tackled scaling each service yet, just trying to connect everything. Given this file, if I <code>docker stack deploy --compose-file docker-compose.yml dev</code> - then what is the correct mongo address for connection string to connect node to mongo? </p>
  
  <pre><code>version: '3'
  
  services:
    node: 
      image: rgilling/rsc:latest
      ports:
        - "8080:8080"
      networks:
        - "core"
        - "front"
      logging:
        driver: "json-file"
        options:
          max-size: "500k"
          max-file: "10"
    db1:
      image: mongo:latest
      ports:
        - "27017:27017"
      command: mongod
      networks:
        - core
      logging:
        driver: "json-file"
        options:
          max-size: "500k"
          max-file: "10"
    search1:
      image: docker.elastic.co/elasticsearch/elasticsearch:5.3.0
      environment:
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      ulimits:
        memlock:
          soft: -1
          hard: -1
        nofile:
          soft: 65536
          hard: 65536
      cap_add:
        - IPC_LOCK
      volumes:
        - ../../elastic/config/search1.yml:/usr/share/elasticsearch/config/elasticsearch.yml
        - ../../elastic/config/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties
        - ../../elastic/logs/search1:/usr/share/elasticsearch/logs/search1
        - ../../elastic/data/search1:/usr/share/elasticsearch/data/search1  
      ports:
        - 9200:9200
      networks:
        - core
      logging:
        driver: "json-file"
        options:
          max-size: "500k"
          max-file: "2"
    kibana:
      image: docker.elastic.co/kibana/kibana:5.3.0
      hostname: test-rep
      volumes:
        - ../../kibana/config/systest.yml:/usr/share/kibana/config/kibana.yml
      networks:
        - core
      ports:
        - "5601:5601"
      depends_on: 
        - search1
      logging:
        driver: "json-file"
        options:
          max-size: "500k"
          max-file: "10"
    mail:
      image: mailhog/mailhog
      hostname: test-mail
      networks:
        - core
      ports:
        - "8025:8025"
        - "1025:1025"
      logging:
        driver: "json-file"
        options:
          max-size: "500k"
          max-file: "10"
  networks: 
    core:
      driver: overlay
    front:
      driver: overlay 
  </code></pre>