docker-compose rabbitmq服务端口覆盖我的节点快速端口

时间:2019-05-22 16:59:39

标签: node.js docker express docker-compose dockerfile

我有一个docker-compose文件,例如:

version: "3.7"

services:
  rabbitmq:
    image: "rabbitmq:latest"
    ports:
      - "15672:15672"
      - "5672:5672"
  hellosign-callback-listener:
    image: ${DOCKER_REGISTRY}blah/hellosign-callback-listener:${DOCKER_IMAGE_LABEL:-latest}
    init: true
    build:
      context: .
      dockerfile: ./debugging/Dockerfile
    ports:
      - "0.0.0.0:8080:8080"
    depends_on:
      - rabbitmq

我的./debugging/Dockerfile如下:

FROM ubuntu:bionic

ENV NODE_ENV=debugging \
    PORT=8080

RUN useradd -ms /bin/bash --uid 999 hellosign

RUN apt-get update && apt-get -qq install \
  curl \
  git \
  gnupg2 \
  netcat

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN curl -sL https://deb.nodesource.com/setup_11.x | bash
RUN apt-get -qq install nodejs
RUN npm install npm@latest -g

COPY package.json .
COPY package-lock.json .

RUN npm install

RUN npm install -g \
  Eficode/wait-for

EXPOSE 8080

COPY src/ .

USER hellosign

ENTRYPOINT [ "node", "server.js" ]

但是,当我通过 docker-compose up hellosign-callback-listener 运行节点应用程序时,我发现它尝试使用的端口是 5672 而不是 8080 。我不明白为什么 5672 似乎会覆盖process.env.PORT以及如何停止它,以便它将使用我希望在节点快递服务器上运行的8080。

编辑

这是 docker-compose ps

的输出
WARNING: The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
                          Name                                         Command               State           Ports
---------------------------------------------------------------------------------------------------------------------------
hellosign-callback-listener_hellosign-callback-listener_1   /bin/sh -c /usr/lib/node_m ...   Up      0.0.0.0:8080->8080/tcp

这是 docker-compose日志hellosign-callback-listener

的输出
WARNING: The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
Attaching to hellosign-callback-listener_hellosign-callback-listener_1
hellosign-callback-listener_1  | { AMQP_SEND_PASSWORD: 'guest',
hellosign-callback-listener_1  |   HOSTNAME: '2433ad7e8f4f',
hellosign-callback-listener_1  |   AMQP_SEND_HOST: 'rabbitmq',
hellosign-callback-listener_1  |   PORT: '5672',
hellosign-callback-listener_1  |   HOME: '/home/hellosign',
hellosign-callback-listener_1  |   AMQP_SEND_PORT: '5672',
hellosign-callback-listener_1  |   AMQP_SEND_LOGGING_TOPIC: 'topic',
hellosign-callback-listener_1  |   PATH:
hellosign-callback-listener_1  |    '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
hellosign-callback-listener_1  |   AMQP_SEND_USERNAME: 'guest',
hellosign-callback-listener_1  |   AMQP_SEND_LOGGING_EXCHANGE: 'firehose',
hellosign-callback-listener_1  |   APPLICATION_ID: '55122888670320',
hellosign-callback-listener_1  |   ORGANISATION_ID: '8632477670016',
hellosign-callback-listener_1  |   PWD: '/usr/src/app',
hellosign-callback-listener_1  |   NODE_ENV: 'debugging',
hellosign-callback-listener_1  |   WAIT_FOR: 'rabbitmq:5672' }

从本质上讲,这是我在节点应用程序中执行console.log(process.env)的过程。

0 个答案:

没有答案