1
00:00:02,120 --> 00:00:03,770
So now with all that information

2
00:00:03,770 --> 00:00:05,900
about volumes and bind mounts,

3
00:00:05,900 --> 00:00:09,310
there is one question which might've come to your mind

4
00:00:09,310 --> 00:00:11,850
and it's related to the stalker file.

5
00:00:11,850 --> 00:00:15,180
If we run a container with our Docker run command,

6
00:00:15,180 --> 00:00:17,930
which we used all the time, this command,

7
00:00:17,930 --> 00:00:22,580
we bind our entire folder here as a bind bound

8
00:00:22,580 --> 00:00:24,690
to make sure that changes in our code

9
00:00:24,690 --> 00:00:28,570
are automatically reflected in the running container.

10
00:00:28,570 --> 00:00:30,840
Now why do we then still copy in

11
00:00:30,840 --> 00:00:33,920
everything here in our Docker file?

12
00:00:33,920 --> 00:00:36,950
I mean, if we use the entire folder as a volume,

13
00:00:36,950 --> 00:00:41,390
as a bind mount anyways, why do we copy in this snapshot

14
00:00:41,390 --> 00:00:42,970
when the image is created?

15
00:00:42,970 --> 00:00:45,510
It's going to get overwritten anyways.

16
00:00:45,510 --> 00:00:48,000
Yes we keep the node modules folder,

17
00:00:48,000 --> 00:00:49,510
but we don't copy that in.

18
00:00:49,510 --> 00:00:51,690
We create that with the NPM install.

19
00:00:51,690 --> 00:00:53,963
So can't we remove this copy step?

20
00:00:55,100 --> 00:00:58,520
Well, yes, we could do that.

21
00:00:58,520 --> 00:01:03,520
If I command this out and I rebuild this image,

22
00:01:03,980 --> 00:01:06,550
so if I build this image again

23
00:01:06,550 --> 00:01:11,550
with a target of feedback node, no copy for example,

24
00:01:15,200 --> 00:01:20,200
if I do that and I wait for this to finish,

25
00:01:21,360 --> 00:01:24,230
I can definitely run this container again.

26
00:01:24,230 --> 00:01:29,230
Now using that no copy tag here after the image tag,

27
00:01:30,080 --> 00:01:31,193
after the image name,

28
00:01:33,440 --> 00:01:36,623
and you will see that this still works fine.

29
00:01:38,150 --> 00:01:41,450
This works, everything works here.

30
00:01:41,450 --> 00:01:46,450
We can also of course view this created file here.

31
00:01:47,520 --> 00:01:48,450
So that works.

32
00:01:48,450 --> 00:01:52,170
So yes, we could remove this if we use a bind Mount,

33
00:01:52,170 --> 00:01:55,460
but there's one important thing about bind mounts,

34
00:01:55,460 --> 00:01:57,670
which you must not forget.

35
00:01:57,670 --> 00:01:59,350
This Docker run command

36
00:01:59,350 --> 00:02:02,160
is the command we use during development.

37
00:02:02,160 --> 00:02:05,170
We use this bind Mount during development

38
00:02:05,170 --> 00:02:07,430
to reflect changes in our code,

39
00:02:07,430 --> 00:02:10,030
into running container instantly.

40
00:02:10,030 --> 00:02:11,920
Once we're done with developing,

41
00:02:11,920 --> 00:02:14,760
and once we actually take this container,

42
00:02:14,760 --> 00:02:18,050
put it onto a server and we want to run it here,

43
00:02:18,050 --> 00:02:20,250
we will not run it with this command.

44
00:02:20,250 --> 00:02:23,920
We will definitely not run it with a bind Mount.

45
00:02:23,920 --> 00:02:27,880
We might use other volumes to ensure that data survives,

46
00:02:27,880 --> 00:02:30,140
but will not use this bind Mount.

47
00:02:30,140 --> 00:02:32,870
Because if the container is running in production

48
00:02:32,870 --> 00:02:35,930
on a server, there is no connected source code,

49
00:02:35,930 --> 00:02:37,860
which updates while it's running.

50
00:02:37,860 --> 00:02:40,440
We will definitely not do that.

51
00:02:40,440 --> 00:02:41,490
In production,

52
00:02:41,490 --> 00:02:44,600
we always want to have a snapshot of our code,

53
00:02:44,600 --> 00:02:48,580
and that's why I keep copy here in the Docker file.

54
00:02:48,580 --> 00:02:53,580
I still want to be able to create snapshot images.

55
00:02:53,720 --> 00:02:56,580
So images with snapshots of our code,

56
00:02:56,580 --> 00:02:59,430
which we then could use to spin up production,

57
00:02:59,430 --> 00:03:01,150
ready containers.

58
00:03:01,150 --> 00:03:03,550
If in addition during development,

59
00:03:03,550 --> 00:03:06,700
we want to have a bind Mount, that's fine, it works.

60
00:03:06,700 --> 00:03:08,980
But we definitely need the option of

61
00:03:08,980 --> 00:03:12,093
creating a snapshot container for production.

62
00:03:13,130 --> 00:03:16,210
I am aware that we haven't learned how to deploy a container

63
00:03:16,210 --> 00:03:19,090
yet, but we will get there later in the course.

64
00:03:19,090 --> 00:03:20,930
Still I hope this makes sense.

65
00:03:20,930 --> 00:03:24,963
And it's clear why we still want to copy in the Docker file.

