Home > front end >  Docker compose for Nodered on linux machine giving curl: (56) Recv failure: Connection reset by peer
Docker compose for Nodered on linux machine giving curl: (56) Recv failure: Connection reset by peer

Time:11-02

I am running my docker compose to start a nodered container on linux machine here are the logs of the container

[info] Server now running at http://127.0.0.1:1886/
[warn] Encrypted credentials not found
[info] Starting flows  
[info] Started flows

But while performing curl on http://127.0.0.1:1886/ it is displaying

curl: (56) Recv failure: Connection reset by peer

.env file

ABCD=99966 EFGH=128 PORT=1886
NODE_RED_CREDENTIAL_SECRET='d7fdsiufhweiu23901ds'

docker compose command

 docker-compose -f XYZ/docker-compose.yml --env-file XYZ/99966/128/.env -p projectname up -d

docker-compose.yml

version: "3.7"

services:
  node-red:
    image: nodered/node-red:latest
    environment:
      ABCD: "${ABCD}"
      EFGH: "${EFGH}"
      PORT: "${PORT}"

    ports:
      - "${PORT}:1880"
    volumes:
      - XYZ/${ABCD}/${EFGH}:/data

I am expecting to run the node-red container using docker compose. I am using settings.js file for authentication using a token.

CodePudding user response:

The port (1886) number printed in the Node-RED logs are what port the service is listening on inside the container.

You have explicitly mapped that to a different value on the host machine with the ports section of the docker-compose.yml file.

    ports:
      - "${PORT}:1880"

This explicitly tells docker to map port 1886 (the value of the PORT env var) on the host to port 1880 on the contain.

Except the container is not listening on port 1880, but on port 1886 as shown in the logs. This is because you have also told Docker to pass the PORT env var into the container so it's in scope when Node-RED starts up so it uses that value. Hence why NR is listening on port 1886 instead of port 1880.

You have 2 choices

  1. Leave the environment section alone and direct map both ports together

    environment:
      ABCD: "${ABCD}"
      EFGH: "${EFGH}"
      PORT: "${PORT}"
    ports:
      - "${PORT}:${PORT}"
    
  2. Remove the PORT entry from the environment section

    environment:
      ABCD: "${ABCD}"
      EFGH: "${EFGH}"
    ports:
      - "${PORT}:1880"
    
  • Related