So now with all that information
about volumes and bind mounts,
there is one question which might've come to your mind
and it's related to the stalker file.
If we run a container with our Docker run command,
which we used all the time, this command,
we bind our entire folder here as a bind bound
to make sure that changes in our code
are automatically reflected in the running container.
Now why do we then still copy in
everything here in our Docker file?
I mean, if we use the entire folder as a volume,
as a bind mount anyways, why do we copy in this snapshot
when the image is created?
It's going to get overwritten anyways.
Yes we keep the node modules folder,
but we don't copy that in.
We create that with the NPM install.
So can't we remove this copy step?
Well, yes, we could do that.
If I command this out and I rebuild this image,
so if I build this image again
with a target of feedback node, no copy for example,
if I do that and I wait for this to finish,
I can definitely run this container again.
Now using that no copy tag here after the image tag,
after the image name,
and you will see that this still works fine.
This works, everything works here.
We can also of course view this created file here.
So that works.
So yes, we could remove this if we use a bind Mount,
but there's one important thing about bind mounts,
which you must not forget.
This Docker run command
is the command we use during development.
We use this bind Mount during development
to reflect changes in our code,
into running container instantly.
Once we're done with developing,
and once we actually take this container,
put it onto a server and we want to run it here,
we will not run it with this command.
We will definitely not run it with a bind Mount.
We might use other volumes to ensure that data survives,
but will not use this bind Mount.
Because if the container is running in production
on a server, there is no connected source code,
which updates while it's running.
We will definitely not do that.
In production,
we always want to have a snapshot of our code,
and that's why I keep copy here in the Docker file.
I still want to be able to create snapshot images.
So images with snapshots of our code,
which we then could use to spin up production,
ready containers.
If in addition during development,
we want to have a bind Mount, that's fine, it works.
But we definitely need the option of
creating a snapshot container for production.
I am aware that we haven't learned how to deploy a container
yet, but we will get there later in the course.
Still I hope this makes sense.
And it's clear why we still want to copy in the Docker file.