Dockerize your React.js Application within 60 Seconds.

Abhishek Vaish
2 min readNov 4, 2020

What is Docker ?

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Docker makes its easier to create and deploy application using the container and run it on any Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

Why Docker ?

  • Keep it simple — Docker’s friendly, CLI-based workflow makes building, sharing, and running containerized applications accessible to developers of all skill levels.
  • Move Fast — Install from a single package to get up and running in minutes. Code and test locally while ensuring consistency between development and production.
  • Collaborate — Use Certified and community-provided images in your project. Push to a cloud-based application registry and collaborate with team members.

For more information refer to Docker documentation which well documented and well structured.

For checking out the docker open-source repository, please click here.

Create a React Application.

Note: Before running these commands please ensure that your system must have node.js install and added to the environment variables.

  • Open your terminal and run :
$ npx create-react-application [folder-name]
  • After successful download of all the packages move inside the folder and run :
$ npm start
  • You are redirect to the React default page and Congratulation you have successfully created your React application. Now move forward and create a Docker file for docker configuration. 👏👏
React.js Default Web Page

Create a Dockerfile

Note: Before running these commands please ensure that your system must have docker install and added to the environment variables.

  • Inside your React Application create a new file Dockerfile.
  • Inside that file write
Dockerfile
  • Open your terminal and run :
$ docker build .
  • Copy the container id given at the bottom of your output and run :
Container-Id
$ docker run -it [container-id]
  • Congratulation you have successfully create your first container based application in React. 👏👏

If you got value from this, and/or if you think this can be improved, please let me know in the comments.

Please share it on Twitter and other social media platforms. Thanks again for reading. 🙏

Follow me on LinkedIn: @abhishek-vaish and Instagram at @abhishek-vaish

--

--