Articles → DOCKER → Hosting The React Application On Docker
Hosting The React Application On Docker
VM Creation
Create A React Application
Give Permission Of “App” Folder To Root User
sudo chown -R root:root /home/demouser/app
Create Dockerfile
FROM node:14
WORKDIR /home/demouser/app
COPY . .
RUN npm install
RUN npm run build
CMD ["npx", "serve", "-s", "build", "-l", "3000"]
Provide Permissions To Root User To Node_Modules
chmod +x /home/demouser/app/node_modules/.bin/react-scripts
Create A Docker Container
docker build -t my-react-app .
Enable 3000 Port For Inbound And Outbound Port In The Virtual Machine
Click to Enlarge
Click to Enlarge
Run React Server In Docker
docker run -p 3000:3000 my-react-app
Output
Click to Enlarge