Create sample app.
npx create-react-app my-app
cd my-app
npm start
Create Dockerfile.
FROM node:18-alpine
WORKDIR /react-docker-example/
COPY public/ /react-docker-example/public
COPY src/ /react-docker-example/src
COPY package.json /react-docker-example/
RUN npm install
CMD ["npm", "start"]
Build and run docker image.
docker image build -t my-app-image:latest .
docker run -dp 65535:3000 --name my-app-container my-app-image:latest
You can display app in a browser at the following URL.
http://<your-ip>:65535
Top comments (0)