'POSTMAN in Docker GET error (connect ECONNREFUSED)

I have a UI running on 127.0.0.1:80 through a docker container. I tested this via Chrome and Postman Client app which works well. When I try to export GET test case from Postman Client app and running it through a separate container, I receive this error:

GET 127.0.0.1:80 [errored]
connect ECONNREFUSED 127.0.0.1:80

here is my docker compose file:

version: "3.7"

services:   
    web:
        build: ui
        ports:
          - 80:80
        depends_on:
          - api
    api:
        build: app
        environment:
          - PORT=80
        ports:
          - 8020:80
    
    test:
        container_name: restful_booker_checks
        build: test
        image: postman_checks
        depends_on:
          - api
          - web

here is my docker file for test cases:

FROM node:10-alpine3.11

RUN apk update && apk upgrade && \
    apk --no-cache --update add gcc musl-dev ca-certificates curl && \
    rm -rf /var/cache/apk/*

RUN npm install -g newman
COPY ./ /test
WORKDIR /test
CMD ["newman", "run", "OCR_POC_v2_tests.json"]

here is the exported json file from Postman Client app:

{
    "info": {
        "_postman_id": "5e702694-fa82-4b9f-8b4e-49afd11330cc",
        "name": "OCR_POC_v2_tests",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        "_exporter_id": "21096887"
    },
    "item": [
        {
            "name": "get",
            "request": {
                "method": "GET",
                "header": [],
                "url": {
                    "raw": "127.0.0.1:80",
                    "host": [
                        "127",
                        "0",
                        "0",
                        "1"
                    ],
                    "port": "80"
                }
            },
            "response": []
        }
    ]
}

When I run the following command, it also works well:

newman run OCR_POC_v2_tests.json

So it's just in docker which the connection can not get through.



Sources

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

Source: Stack Overflow

Solution Source