React app exiting in docker container with exit code 0

后端 未结 4 2081
无人共我
无人共我 2020-11-27 07:48

I am trying to create a docker-compose setup with nginzx, flask, and react. I started my react app with react-create-app (https://github.com/facebook/create-react-app) and h

相关标签:
4条回答
  • 2020-11-27 08:19

    As the issue is with react-scripts version > 3.4.0 as with the posted link from sandeep-reddy, you could pin the version that is installed by using these lines in the Dockerfile (credit Michael Herman).

    Edit: Looks like you still need the line stdin_open:true in docker-compose.yml file for it to work.

    RUN npm ci
    RUN npm install react-scripts@3.4.0 -g --silent
    
    0 讨论(0)
  • 2020-11-27 08:22

    Adding: stdin_open: true to the React component of my docker-compose file fixed my issue.

    Example:

    version: '3.1'
    
    services:
        react:
            build:
                context: ../react-app/
                dockerfile: ./Dockerfile
            container_name: react
            volumes:
                - ../react-app:/usr/src/app
            networks:
                my-network:
                    aliases:
                        - react-app
            expose:
                - 3000
            ports:
                - "3000:3000"
            stdin_open: true
    
    0 讨论(0)
  • 2020-11-27 08:25

    It looks like an issue with [React-Scripts] v3.4.1. Please look into this link

    0 讨论(0)
  • 2020-11-27 08:37

    Ran into same issue. Below mentioned steps resolved my problem: 1. add stdin_open: true

    version: '3.1'
    
    services:
      nginx:
        .
        .
      react:
        stdin_open: true
        .
        .
    

    2. Do not forget to build the container again after the above mentioned change is made.

    docker-compose down
    docker-compose up --build
    
    0 讨论(0)
提交回复
热议问题