Docker in your React Project within 2 minutes
Docker link: https://docs.docker.com/
What is Docker and Why?
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Things in Docker you have to know.
Container: This is a running process/instance of an image. A docker container ‘contains’ everything your application needs to run and can run your application in any environment
Images: A docker image contains everything you need to run your application.
Dockerfile: A docker file isa set of instructions that defines how your image is built. It is a series of steps that you have defined, and that must happen before your image is successfully built.
Dockerignore: The .dockerignore file acts like the .gitignore file. It contains any file in your local application that you do not want in your docker image.
Get Start now…
Goto console after installing Docker.
Clone Repo: git clone https://github.com/linkon63/Docker-React.git
Then type code. it will open vs code then open console vs code and type docker -v it will show like picture
Then in console type this docker build -t nameofyourapp:latest .
in nameofyourapp it will app name like mine is React-Docker
so docker build -t React-Docker:latest .
To run our docker container, in your terminal write the command:
docker run — name nameofyourchoice -d -p 3000:3000 nameofyourapp:latest
— Name of your Project —
docker run — name React-Docker -d -p 3000:3000 React-Docekr:latest
After your container runs successfully, you will one id in the console
Then Go to the Container and Start your project And You will see your Project.
What you should see is a simple page that says “Hello Docker you are in React Now”