Skip to content

2 docker-compose files / no requests through bridge possible #5512

Closed

Description

@martinmakesitwork

Hi everyone!

I have two docker compose files:

version: '3.2'
services:
  web:
    build: .
    ports:
     - "8080:8080"
    external_links:
     - app
    networks:
     - wordnet
networks:
  wordnet:
    external: true

and

version: '3.2'
services:
  app:
    image: "node:8"
    user: "node"
    container_name: app
    ports:
      - '3000:3000'
    networks:
      - wordnet
    external_links:
      - web
    command: "npm start"

networks:
  wordnet:
    external: true

One for the app and one for the corresponding website. My problem is that im not able to get infos from the app container. I tried this:

  var options = {
    host: 'localhost',
    port: 3000,
    path: '/stats/123/today'
  };

  http.get(options, function (resp) {
    console.log(resp);
  }).on('error', function (err) {
    console.log("Error:", err)
  });

then this error occures:

{"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000}

and i tried this:

  var options = {
    host: 'http//app',
    port: 3000,
    path: '/stats/123/today'
  };

  http.get(options, function (resp) {
    res.send(resp);
  }).on('error', function (err) {
    console.log("Error:", err)
  });

then this error occures
{"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo","hostname":"http//app","host":"http//app","port":3000}

I have no idea how to handle this problem. My network uses the bridge driver.

Activity

  1. shin- commented on Dec 27, 2017

    @shin-
    1. http is the protocol, it's not part of the hostname.
    2. the separator between protocol and hostname in URLs in ://, not //
    3. You don't need to specify the protocol at all in this instance, since a request made with the http node module will obviously be an HTTP request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions