即使Package.json具有““ start”:“ set PORT = 3500 && react-scripts start”,带有React-Service的Docker-compose始终会选择PORT 3000

问题描述

我正在使用docker-compose运行一些微服务:

Dockerfile:

FROM node:alpine
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
COPY . .
CMD ["npm","run","start"]

docker-compose.yaml:

version: '3'
services:
  lb:
    image: dockercloud/haproxy
    links:
      - api-gateway
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 80:80
      - 443:443
    restart: on-failure

  api-gateway:
    build:
      context: .
      dockerfile: development.Dockerfile
    image: microservices-workshop/api-gateway:dev
    restart: on-failure
    environment:
      - VIRTUAL_HOST=api-gateway.app.com
    ports:
      - 3000:3000
    volumes:
      - ./api-gateway:/app/src

  delivery-service:
    build:
      context: .
      dockerfile: development.Dockerfile
    image: microservices-workshop/delivery-service:dev
    restart: on-failure
    volumes:
      - ./delivery-service:/app/src

  order-service:
    build:
      context: .
      dockerfile: development.Dockerfile
    image: microservices-workshop/order-service:dev
    restart: on-failure
    volumes:
      - ./order-service:/app/src

  restaurants-service:
    build:
      context: .
      dockerfile: development.Dockerfile
    image: microservices-workshop/restaurants-service:dev
    restart: on-failure
    volumes:
      - ./restaurants-service:/app/src

  react-service:
    build:
      context: ./react-service
      dockerfile: Dockerfile
    volumes:
      - /node_modules
      - ./react-service:/src
    tty: true
    ports:
      - 3500:3500

这是React应用的Package.JSON:

{
  "name": "reactservice","version": "0.1.0","private": true,"dependencies": {
    "@testing-library/jest-dom": "^4.2.4","@testing-library/react": "^9.5.0","@testing-library/user-event": "^7.2.1","react": "^16.13.1","react-dom": "^16.13.1","react-scripts": "3.4.2"
  },"scripts": {
    "start": "set PORT=3500 && react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject"
  },"eslintConfig": {
    "extends": "react-app"
  },"browserslist": {
    "production": [
      ">0.2%","not dead","not op_mini all"
    ],"development": [
      "last 1 chrome version","last 1 firefox version","last 1 safari version"
    ]
  }
}

但是当我按下docker-compose up时,我得到了:

Compiled successfully!
react-service_1        |
react-service_1        | You can now view reactservice in the browser.
react-service_1        |
react-service_1        |   Local:            http://localhost:3000
react-service_1        |   On Your Network:  http://172.20.0.4:3000
react-service_1        |
react-service_1        | Note that the development build is not optimized.
react-service_1        | To create a production build,use npm run build.
react-service_1        |
                                                                          

...即使我已将端口设置为3500

我哪里出错了?

顺便说一句,我在WINDOWS 10下工作

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...