Resolving "react exit with code 0" when running a React container
So, before you'll get this error on your Docker instance I presume you have basic knowledge of Docker and as such won't need to explain but rather straight to the error and solution options.
The Error
The error is gotten when you run the below command on a set of projects that include a React App.
docker-composer up
or try to start a React App container from an image on your Docker instance.
For the simplest solution, Skip to Option 5 :wink:
Option 1
(While Running Multiple Containers)
Add the configuration "tty:true" to your react instance
react:
tty: true //NOTE
build: dockerreact
ports:
- "3000:3000"
Option 2
(While Running Multiple Containers)
Setting "stdin_open:true" to your react instance
react:
stdin_open: true //NOTE:
build: dockerreact
ports:
- "3000:3000"
Option 3
(While Running Multiple Containers or Single React Container)
Add "CI=true" as a command that should run before "npm install" in your Dockerfile within your React project root directory
FROM node:14.5
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN CI=true //NOTE
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
CMD ["npm","start"]
Option 4
(While Running Multiple Containers or Single React Container)
Use "docker-compose run" instead of "docker-compose up" as this automatically sets either option 1 or 2 as true
docker-compose run
NOTE: This is only works on already built docker images
Option 5
(While Running Multiple Containers or Single React Container)
Lastly, Degrade your "react scripts" version to 3.4.0
NOTE: Degradding to 3.3.0 wont solve the error.
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.0", //NOTE
"react-scripts": "3.4.1" //NOT WORKING
},
NULL_RECORDS // No data found
Environmental Variables in Python
Before we begin let's look at our little vocabulary: ENV = Environmental Variable, ENVs = Environmental Variables. A guide on using ENVs for automation and security in Python scripts.
Fixing Failed NPM TEST on Default Ember Boilerplate on Linux
A guide for Linux users on resolving issues with the default Ember test process that expects Chrome to be installed.