Now with the bind mount added,
if we changed the HTML files,
those changes are instantly reflected,
when we reload the app here.
You'll notice a problem though,
if you change something in server JS.
So Indy JavaScript code,
which is executed by a note.
Let's say there, for example,
I simply want to console log, test here.
Just to change anything.
So I wanna Log test here,
whenever we save a new feedback.
Now my container is still up and running.
You can always check this with Docker PS, of course.
And therefore if I reload, and I try this,
of course it works, but to now see whether,
we also see that log.
We can, of course now use Docker logs
feedback-app.
And we see nothing here.
There is absolutely nothing.
So somehow this wasn't logged.
And that's a node specific problem,
but you might face similar issues
in other applications as well.
This code in server JS is executed by node,
by the node runtime.
And it that runtime, and that file being executed.
Which is responsible for us seeing this page
and having a working web server.
Now we need to restart the web server,
to pick up changes in the JavaScript code
that is used by that server.
We don't need to restart the entire container,
but just the web server.
Now, if the container is already running,
restarting just the server in that container,
is not really trivial though.
So actually, the best thing we can do here,
is to simply stop that container
and then restart it thereafter.
At least we don't need to rebuild the image.
But by stopping and restarting,
we start a new node server,
which will pick up this server JS file.
But of course, since I added --rm
when I created the container,
actually we can't start it again,
because it was deleted once I stopped it.
So here I would have to run Docker, run again.
But with that done, if I now reload,
this should work.
And I save here,
we should now be able to see the logs.
If we use Docker logs feedback-app.
Here it is.
So it's better than having to rebuild the entire image,
but still not great.
Now for note JS, that's a common problem though.
And you might also be facing it
if you're just developing locally without Docker at all.
And there is a useful extra package,
which we can use in node JS development,
which will watch the file system,
and which will restart the node server,
whenever a file changed.
It's a package which be used during development,
therefore, to ensure that changes are reflected instantly.
And for that here in packaged.json,
you should add a devDependencies node,
next to dependencies.
And in their, add nodemon.
And then the version 2.0.4, for example.
That's now an extra dependency added to this project.
And now we can run server JS,
with this nodemon package,
instead off with node itself.
Under the hood nodemon of course uses node,
but it has this extra file change watcher,
which ensures that, we are made aware of
changes in our files.
For that We should add a script section,
a scripts section to package.json as well.
And in there add a script named start,
and type nodemon server.js in here.
And now we can run this script here
to use nodemon, to start our server,
Instead of node.
With that done we now also need to tweak our Docker file,
to utilize this new script
and use this script to start our process,
our server.
Instead of using node.
And they offer in the Docker file,
the command you wanna execute is now actually npm start.
Which uses this start script,
which then under the hood uses nodemon.
So if we now saved this,
we need to remove our
feedback-node:volumes image.
And for that, of course, I first of all,
needs to stop my feedback app container.
Otherwise the image is still in use.
So let's do that first.
Then remove the image
and then build the image again to pick up this new
command here at the end.
And once that is all done,
we can of course use our Docker run command again,
to bring this server back up,
now using this latest image.
And now the key difference is that
this server should now automatically restart,
whenever we change anything in server JS.
So if I add a couple of exclamation marks here,
for example, in this log statement,
and I saved this.
If I now test 4,
test this.
This all works,
but now if I run Docker logs feedback-app,
we see these exclamation marks here.
And we actually also see some output from nodemon,
which proves that it works.
You'll see that it started and you'll see that it,
for example, restarted due to changes here.
Now I got an important note for windows users,
especially when you're using WSL2
for running Docker on windows.
If you're doing that,
you might notice that,
when for me, file changes
do reload D development server,
and everything does work as shown in the lecture,
it doesn't work for you.
The reason for that is that, when using WSL2,
you should store your project and your project files,
directly in the Linux file system
in the end.
So somewhere in the Linux file system,
not your regular windows file system.
Now you might wonder how you get to this Linux file system,
attached you'll find a link.
You find a link to this article,
which explains how you can mount and work
with this Linux file system.
Where if you then have your project in there,
your changes will propagate to the Docker container.
And therefore they should update as shown.
If you use the regular windows file system,
file changes are not propagated to the Docker container,
and therefore not picked up by tools like nodemon.