·reference https://engineer-ninaritai.com/docker-react/
What you can do Open React page using Docker
Dockerfile
FROM node:14.13.1
WORKDIR /usr/src/app/
docker-compose.yml
version: '3'
services:
node:
build:
context: .
tty: true
environment:
- NODE_ENV=development
volumes:
- ./:/usr/src/app
command: sh -c "cd reactapp && npm start"
ports:
- "3000:3000"
Execute docker command in the directory where docker-compose.yml is located
docker-compose build
Create react app
docker-compose run --rm node sh -c "npm install -g create-react-app && create-react-app reactapp"
launch react app
docker-compose up
Success if you can access it on localhost: 3000!
Personal notes Enter the container docker exec -it container name bash Install react-router npm install -S react-router-dom install material-ui npm install @material-ui/core
Recommended Posts