[Intro Music]
Alright guys, we have just explored
the python container, and we have
created a couple of sample Python
applications. And now it's a good
time to move on. And now let's try
and run another container Node.js
container. And let me first show
you that at the moment, we don't
have Node.js installed on this
computer. If I'll type 'node
-v', I'll see, 'command not
found: node'. And that means that Node.js
along with NPM actually are not
installed on this computer. Now,
let's suppose that you want to
create the Node.js application and
run it using node. But you don't
want to install node on your
computer. Or, for example, you want
to run your application using a
specific version of node that
differs from the version that is
installed on your computer. In
such case Docker will help you.
Let's now create Node.js
container, and first let's pull Node.
js image from Docker Hub. And let's
create a very simple Node.js
application that will print simply
'Hello from Node.js application' to
the terminal. Let's do that. Let's
clear terminal. And let me
first look at containers that
are currently running. There are no
such containers. But if I have a
look at history, I will see a bunch
of python containers. And let me
prune them quickly. And for that we
could use command 'docker container
prune', like so. And all containers,
stopped containers will be deleted.
'docker ps -a', and now I see that
there are no stopped containers. And
notice that we have reclaimed
around 10 megabytes of disk space
that was utilized by those stopped
containers. Great. Let me now clear
terminal. And now let's pull Node.
js image. And lets use first layer
stack it is default one. 'docker
pull node', Enter, 'Pulling from
library/node'. And you see that this
image has multiple 'fs' layers. Let's
wait a bit until download and
extraction will be completed.
Meanwhile, let me tell you a few
words about Node. Node.js is
basically backend JavaScript
framework that allows you pretty
easily and faster create any
JavaScript backend applications.
And you're able, for example, create
API using JavaScript and run it on
your backend servers, or you could
perform any operations with file
system. And in this course, we will
try to create a sample
application that will create the
new files in your working directory
and so on. So that's Node.js. And
usually it is used in conjunction
with frontend JavaScript
frameworks like React or Vue or
Angular, and you're able to create
the JavaScript microservices
on frontend and on backend, that
simplifies actually, entire
development workflow. Okay, pull
and extraction were completed, and
now we have node image locally in
our cache, and we could verify that
'docker images'. And yes, here is
node in this list. And you see that
its size is approximately the same
as size of python image. Here you
see those sizes and both of them
are around one gigabyte in size.
Great. Let's now create the Node.js
container and let's simply create it
first using the 'docker run node'
command, like so. 'docker run node',
container was created, process was
terminated, and container was
stopped as well, as usually. 'docker
ps', there are no containers
running. Let's now run this
container in interactive mode with
options '-i' and '-t'. 'docker
run -it node'. And now I see
prompt, 'Welcome to Node.js v13.13.0'.
And in your case, you
may see another version, because
tag 'latest' may be assigned to
different images at different
moments of time. For example, when
there is a new stable version of
image is released, then tag 'latest'
is assigned to that new version.
Great, you are able to type for
example, 'help' here, '.help', and
you'll see some basic commands that
you are able to utilize in this
Node.js interpreter, because we are
actually connected now to Node.js
interpreter. And we are able to
execute some JavaScript commands
directly here. For example, let's
type console.log('Hello from Node.
js container')', like so, press Enter.
And you see 'Hello from Node.js
container' here in terminal. Great.
That's how we were able to connect
to interactive shell inside of
the Node.js container where you're
able to execute any JavaScript
commands, or you could type for
example 10 + 5, and you should
get 15 here in the terminal, or you
could create a new variable, for
example, let's create variable 'a' and
assign the value to it, 10, and
here we are able to access variable
10 and in such case you will see
its value here in the terminal.
Great. Are you able to interact with
Node.js
interpreter? Let's go out of it.
And actually you need to type a '.exit'
in order to exit from this
interactive shell like so. Process
was terminated, and now container
was stopped. 'docker ps', there are no
containers running. Great. Let's
next create the sample Node.js
application, and run it using Node.
js container. Let's do that next. Bye-Bye.
[no audio]