1
00:00:02,100 --> 00:00:03,420
Over the last lectures,

2
00:00:03,420 --> 00:00:07,210
we learned that Docker has some pretty nice features,

3
00:00:07,210 --> 00:00:11,080
when it comes to requests leaving one container

4
00:00:11,080 --> 00:00:12,540
and going to the host machine

5
00:00:12,540 --> 00:00:14,380
or going to another container.

6
00:00:14,380 --> 00:00:17,660
Specifically, we can use host docker internal

7
00:00:17,660 --> 00:00:20,690
as an address to target the host machine,

8
00:00:20,690 --> 00:00:23,400
in case some services running there.

9
00:00:23,400 --> 00:00:26,880
And you just learned about container networks

10
00:00:26,880 --> 00:00:28,960
and that when you use them

11
00:00:28,960 --> 00:00:32,290
and multiple containers are in the same network,

12
00:00:32,290 --> 00:00:36,150
you can actually use the name of a container as a domain,

13
00:00:36,150 --> 00:00:40,040
as an address, and Docker will automatically resolve

14
00:00:40,040 --> 00:00:42,250
the IP addresses.

15
00:00:42,250 --> 00:00:43,750
That's a cool feature.

16
00:00:43,750 --> 00:00:47,600
I just want to ensure that we all understand it correctly.

17
00:00:47,600 --> 00:00:52,060
Docker will not, important, not go ahead

18
00:00:52,060 --> 00:00:55,924
and start replacing your source code under the hood.

19
00:00:55,924 --> 00:00:57,640
That is not what it's doing.

20
00:00:57,640 --> 00:01:00,470
It's not replacing your source code.

21
00:01:00,470 --> 00:01:02,800
So it will not read your source code,

22
00:01:02,800 --> 00:01:06,303
see a container name and plug in the IP address

23
00:01:06,303 --> 00:01:08,660
of that container into your code.

24
00:01:08,660 --> 00:01:10,290
That would be way too complex

25
00:01:10,290 --> 00:01:12,120
and it's not what it's doing.

26
00:01:12,120 --> 00:01:15,000
Instead Docker owns the environment

27
00:01:15,000 --> 00:01:16,800
in which your application runs.

28
00:01:16,800 --> 00:01:20,830
And if your application sends an HTTP request

29
00:01:20,830 --> 00:01:23,640
or a MongoDB request or any other kind

30
00:01:23,640 --> 00:01:26,930
of request that leaves the container,

31
00:01:26,930 --> 00:01:29,400
then Docker is aware of that.

32
00:01:29,400 --> 00:01:32,270
And it's that point of time where Docker

33
00:01:32,270 --> 00:01:35,470
then is able to resolve the address,

34
00:01:35,470 --> 00:01:39,840
or the container name or host Docker internal

35
00:01:39,840 --> 00:01:42,850
and replace it with the actual IP address,

36
00:01:42,850 --> 00:01:45,319
since it is aware of the surrounding containers

37
00:01:45,319 --> 00:01:47,810
and the host machine.

38
00:01:47,810 --> 00:01:50,940
So it's only when a request leaves the container.

39
00:01:50,940 --> 00:01:53,600
If a request does not leave a container,

40
00:01:53,600 --> 00:01:57,440
or if a request is generated somewhere else,

41
00:01:57,440 --> 00:01:59,490
for example, in the browser.

42
00:01:59,490 --> 00:02:02,840
If users are visiting your web app and JavaScript code

43
00:02:02,840 --> 00:02:04,410
is running in their browser

44
00:02:04,410 --> 00:02:06,750
and a request is sent from there,

45
00:02:06,750 --> 00:02:09,060
then Docker is not doing anything

46
00:02:09,060 --> 00:02:12,430
because it's not replacing the source code.

47
00:02:12,430 --> 00:02:15,380
That's just important that we all understand

48
00:02:15,380 --> 00:02:18,420
how that auto IP resolving feature

49
00:02:18,420 --> 00:02:20,523
actually works under the hood.

