Imagine you have created a React application, and now you want to test the application by sharing it with your friend. However, your friend is encountering difficulties while trying to run the application. So, how can we solve this problem? Here comes the concept of containerization.
Creating React App
Create a React app by using the following command
where client is the name of your react app
Creating Dockerfile
Navigate to the client (React app), create a file named Dockerfile, and then open the file. You can refer to the following image for guidance.
Code to create a Docker image
Build Docker image
Build the Docker image using the following command, where "docker-react" is the name of the image (you can change it if needed).
Run the image
Execute the image using the following command, where "docker-react" is the name of the image. Replace it with your image name.
Open your localhost:3000
Launch localhost:3000 in your browser to view the output.