In this video, you will learn how to run a Node.js project using Docker in just 5 minutes. This node js docker tutorial is perfect for beginners who want to containerize their application quickly and easily.
We will cover everything step by step, so you can understand how node js docker works in real-world projects. Whether you are new to Docker or already familiar with Node.js, this guide will help you set up your environment without any confusion.
By the end of this tutorial, you will clearly understand how to use Docker with Nodejs to build, run, and manage your applications efficiently.
ЁЯФе What you will learn:
How to setup Node.js with Docker
How to create a Dockerfile for Node.js project
How to run Node.js app inside Docker container
Fast and simple deployment process
If you are looking for a quick and practical node js docker tutorial, this video is for you. Watch till the end and try it yourself!
#NodeJSDocker
#NodeJSDockerTutorial
#DockerWithNodejs
#DockerTutorial
#NodeJS
#Docker
Show More Show Less View Video Transcript
0:01
Hi friends, welcome to tutors funny
0:03
channel. Today I'm going to teach how to
0:07
configure the fun NodeJS projects into
0:11
docker. Okay. So how to run the NodeJS
0:14
project in docker. So I'll be explain
0:17
each and every things in detail. Okay.
0:20
So first I'm going to go to the d drive.
0:23
So I'm going to create not
0:29
project
0:33
docker.
0:36
Okay. So I'm going to
0:39
open the cmd to create the simple node
0:43
project. Okay. So you open up the nodejs
0:48
here. What I'm going to do is I'm going
0:50
to go to create the file index.js.
0:55
Okay. this file. What I'm going to do is
0:58
I'm going to
1:00
uh
1:02
I'm going to paste this simple code the
1:06
NodeJS code. Okay. So the simple code
1:09
what I'm going to do is here I'm going
1:11
to this is the express which which
1:14
nothing but the uh NodeJS back end which
1:17
is a express we have to install the
1:19
express then only we can work as a uh
1:23
exer. Okay. So after that we have to
1:26
cross. Okay. So here we have a endpoint
1:28
we have communicate the uh endpoint and
1:31
my endpoint which is nothing but uh uh
1:36
this ur okay. So this express we have to
1:39
call the express this a port
1:42
uh express is running. So here after
1:46
that we have here this one should be our
1:47
response. Get the response. Okay get the
1:51
request and response here server is
1:53
running or not.
1:55
everything you are checking in the
1:56
index.js JS okay this is the port which
1:58
you'll be running okay the simple code
2:01
uh this simple uh NodeJS project how
2:04
will be configure into the docker so
2:07
it's very easy process okay so what
2:10
you're going to is I'm going to go to
2:12
this my project okay so what I'm going
2:14
to here first I'm going to go to the
2:17
create the docker file so how to create
2:18
the docker file so you have to create
2:20
right click you have to click on it the
2:23
file
2:24
you have type docker file get
2:27
type doc. So do file
2:31
automatically the the symbol will be
2:35
change according. So after that the
2:37
important thing you have to do it this
2:39
is must you have to go to that extension
2:42
that is a must.
2:44
Okay. So that for the extension here you
2:46
have to search docker
2:52
click on it. I uh at the moment I have
2:55
installed. If you not installed there is
2:57
a button called install. You can click
2:59
and install it. This is the thing you
3:01
must do it. Okay. Before you configure
3:03
it, you must do this things. Okay. After
3:07
that what I'm going to do is I have to
3:09
I'm going to go to open up my docker
3:11
desktop. I already installed. If you
3:14
don't know how to insert Docker uh in my
3:17
I have uh attached the video description
3:19
in my how to install the Docker step by
3:21
step. I having a code uh I having a
3:24
video you just click on the link and you
3:26
will be you will be able to watch it.
3:27
Okay. So I already here the docker
3:30
desktop is open do you have you must
3:32
check out okay different
3:35
that's the thing you have to do file you
3:38
have created uh now the docker file what
3:42
you going to do it here this is things
3:44
okay you no need to write okay this just
3:47
copy this one you paste it. So what the
3:49
things you must know here
3:53
note this is a 18 the version 18 you
3:56
have convert the versions you have to
3:57
implement the versions after the work
3:59
directory app you have write work
4:01
directory app you have to write it like
4:03
this copy package JSON okay before that
4:07
what you're going to do is I'm going to
4:09
open up my terminal window I have to
4:11
create the all the things so what you're
4:13
going to do is you have to normally we
4:16
have to install that okay you have to
4:18
Right. This one mpm init y. Okay. Right.
4:24
Sorry. Sorry.
4:27
Clear up this one. I'm going to install
4:29
the node project packages first. Okay.
4:32
All the node packages will install it
4:34
before that. Okay. So, I'm going to
4:36
install the this one.
4:40
So, I having some problem with my
4:43
terminal window. So I so that I'm going
4:46
to go to my project here open the
4:49
terminal window here I'll be able to
4:51
install it I have a simple problem okay
4:54
so I want to solve out my
4:58
uh
5:02
VS code there is no that that is not a
5:06
error it's some configuration problems
5:08
shows of that uh VS code it installed
5:11
successfully now what I'm going to paste
5:14
this as well express and cross. These
5:16
two things I am installed.
5:19
Okay, these two dependencies are very
5:21
must.
5:22
Okay, in order to run the NodeJS
5:25
project. Okay, this express which is
5:27
server. This is the cross. This is the
5:29
endpoint get managed with the URL and
5:31
all. Okay. So this one these two things
5:34
when you connect with the front end to
5:36
back end this cross is very important.
5:39
Okay. it it manage the URL endpoints
5:42
that it is it is managing by the URL
5:44
endpoint these two things I have
5:46
installed successfully okay now now
5:48
you'll be able to see there is a node
5:50
modules and you will be able to see this
5:52
package JSON and uh lock json package
5:55
this all the JSON profiles are there now
5:58
here for the docker what I did is copy
6:02
package
6:04
all JSN mean this all the JSON file are
6:08
copied
6:09
Okay, this all JSON all the dependencies
6:12
are copied here. After that, MPM
6:15
install. Run mpm install. You run this
6:17
mpm install. Okay, you have to type type
6:20
mpm install. Copy all. Copy all the
6:22
files. Expose 5,000. This is a 5,000
6:26
port the app is running. If you want to
6:29
change the port, you must change here as
6:32
well. Both we must change it. After that
6:36
you can see node you have to you
6:38
normally you have to how to run the node
6:39
uh app node index.js. Here also the
6:43
command you have to type it. Uh command
6:46
you have to provide in the docker file
6:48
node index.js. This is a simple way we
6:51
have implement. Okay. Very simple.
6:54
Normally we have to install them. After
6:56
that run the node project node index.js.
6:59
This this how we have run the project.
7:01
Right. This how we can run the project.
7:02
Okay. Okay. Yes, the port is
7:04
implemented. It is running. This we have
7:06
run the project. Okay, I haven't saved
7:08
it. That's why the port is not changed.
7:10
Okay, this how we can run the project.
7:11
So, I'm just uh cancel it. Okay, so I'm
7:15
going to save this project. Okay, so now
7:18
instead of this way, we have to run this
7:20
project using docker. Okay, so docker
7:23
you have to configure the project like
7:25
docker. Now what I'm going to do is I'm
7:27
going to here you have changed the port
7:28
and all. Okay, so now what I I have save
7:31
it and everything's completed. Now I
7:33
what I'm going to do is I have to do the
7:36
setup on how to run the docker file. You
7:39
have to run the command docker build t
7:42
my app r. This is the command we have to
7:44
copy. Okay. This command. Don't worry
7:47
it's here. Just okay. So I have to type
7:49
docker build. Okay. iPhone t my node app
7:55
on this is simple command you have to
7:57
type. Okay. This simple command you have
8:00
to type to build the server. You can
8:02
Okay. press enter key on your keyboard.
8:04
It takes some time to configure your
8:06
app. You have to wait until the uh all
8:10
the installation part is completed. It
8:13
takes some time to complete. So it's
8:14
completed here. Now it's completed that
8:17
the first time if you install it takes
8:18
some time to complete. Now it's
8:19
completed successfully here. Now after
8:21
that what you going if it is completed
8:23
now I'm going to run the another
8:26
command.
8:27
This is a server. So that server I'm
8:29
going to the port I'm going to change
8:32
change this is 6 500 instead of five
8:36
5,000 I already change it as a 6,000.
8:40
Okay that's the things this how we can
8:42
run this percent key.
8:46
Okay now it's done. So how to uh how how
8:51
will we check whether it's working fine
8:53
or not? Very simple. You have to go to
8:55
the localost
8:59
port 6,0004
9:03
press enter key.
9:05
This is might be the uh browser issues.
9:09
How can we solve them? Simple is uh I'm
9:14
going to go to change the port as 3000.
9:19
uh the docker also we can change the
9:22
port as 3000 this might be the our
9:26
server issues okay server issues when
9:28
you get a server issues it takes some
9:30
time okay now what I'm save all you must
9:33
configure that to save all now what I'm
9:35
going I'm going to go to run again uh
9:39
I'm going to build the app again.
9:49
Okay, after that I'm going to run the
9:52
command
9:56
this one. Run the app.
10:01
Now it's running. I'm going to go to
10:06
it here. Now it's working. Okay, it's
10:09
some it it might be the some port
10:13
issues. Okay, the browser refused the
10:15
port. So you will be able to run like
10:17
this. You will be short out the Okay,
10:19
thank you for watching.
#Jobs & Education

