1
00:00:04,240 --> 00:00:11,500
We have just successfully created a new container using image called phpMyAdmin slash phpMyAdmin.

2
00:00:11,530 --> 00:00:14,410
It is not an official Docker hub image.

3
00:00:14,410 --> 00:00:20,710
That's why we needed to use this prefix that is actually name of specific user or organization that

4
00:00:20,710 --> 00:00:23,500
has published specific image at Docker Hub.

5
00:00:23,530 --> 00:00:30,460
But this image indeed is very popular and it is used for management of the MySQL database over graphical

6
00:00:30,460 --> 00:00:31,750
user interface.

7
00:00:31,750 --> 00:00:39,220
And now here on this page we see actually welcome page for phpMyAdmin, but we are not able to set the

8
00:00:39,220 --> 00:00:41,860
connection details for MySQL server.

9
00:00:41,860 --> 00:00:48,100
I'm talking about hostname or IP address, but we are able to set username and password for connection

10
00:00:48,100 --> 00:00:49,690
to MySQL server.

11
00:00:49,690 --> 00:00:56,320
And now in this lecture I'll demonstrate you how we are able to set location of the MySQL server for

12
00:00:56,530 --> 00:00:58,060
phpMyAdmin container.

13
00:00:58,060 --> 00:01:03,130
And first let me go to web page where we have downloaded phpMyAdmin image.

14
00:01:03,130 --> 00:01:07,850
It was Docker hub and here is this page in this history list.

15
00:01:08,240 --> 00:01:19,880
Let's go there and let me scroll a bit down to section that explains how we are able to set custom location

16
00:01:19,910 --> 00:01:21,650
of the MySQL server.

17
00:01:21,650 --> 00:01:24,410
Here it is usage with external server.

18
00:01:24,560 --> 00:01:32,810
Now technically MySQL server MySQL container is external related to phpMyAdmin container because they

19
00:01:32,810 --> 00:01:38,720
are currently running at two different servers, two different containers that have different IP addresses.

20
00:01:38,720 --> 00:01:46,670
And if it is the case you need to use this option environment variable PMA underscore Host Let me make

21
00:01:46,670 --> 00:01:48,350
it a bit larger like so.

22
00:01:48,350 --> 00:01:55,250
And here you will see this environment variable and you are able to set it either to hostname of the

23
00:01:55,250 --> 00:01:58,520
MySQL server or use IP address.

24
00:01:58,520 --> 00:02:04,730
And let's first use IP address and see whether we will be able to connect to MySQL server or not.

25
00:02:04,730 --> 00:02:11,870
All right, let's go back to terminal and let's actually stop container phpMyAdmin container that is

26
00:02:11,870 --> 00:02:12,740
currently running.

27
00:02:12,740 --> 00:02:20,630
Let's use control C shutting down this process accepts sigterm signal and actually seek enter should

28
00:02:20,630 --> 00:02:25,910
be sent, but probably seek INT is converted in this case to sigterm.

29
00:02:25,910 --> 00:02:32,840
All right, let's clear terminal and let's again start phpMyAdmin container but now with additional

30
00:02:32,840 --> 00:02:39,590
environment variable dash E but I have told you that we want to set IP address of the MySQL server in

31
00:02:39,590 --> 00:02:47,300
this environment variable Host And first let's find out which IP address is currently used by MySQL

32
00:02:47,300 --> 00:02:48,050
container.

33
00:02:48,080 --> 00:02:53,750
Let's list containers Docker PS and here is currently only MySQL server running.

34
00:02:53,750 --> 00:03:01,220
Let's use Docker exec command here 49 and here let's open up Shell.

35
00:03:01,550 --> 00:03:09,640
And actually I need to add here, dash it like so and here you are able to type hostname dash I and

36
00:03:09,640 --> 00:03:18,280
you'll find out IP address of this container 172 1702 Let me copy it and actually you are able to find

37
00:03:18,280 --> 00:03:24,820
out the IP address of specific container by entering Docker inspect command and here will be ID of the

38
00:03:24,820 --> 00:03:29,830
container this 149 and you'll see same IP address here.

39
00:03:29,950 --> 00:03:35,440
Again, there are two different ways or even more if you want to find out IP address of the container,

40
00:03:35,440 --> 00:03:37,210
you are able to use any of them.

41
00:03:37,210 --> 00:03:37,870
Great.

42
00:03:37,870 --> 00:03:45,070
Let's now clear terminal and let's use Docker run command and let's use again phpMyAdmin with exposed

43
00:03:45,070 --> 00:03:52,480
port dash P external port 8080 internal port 80 and here will be environment variable dash E.

44
00:03:52,570 --> 00:03:58,120
Let's go back to Chrome and here is name of the variable PMA underscore host.

45
00:03:58,150 --> 00:04:02,710
Let's use it PMA underscore host equal sign.

46
00:04:02,710 --> 00:04:06,140
And here let's paste IP address that we have copied.

47
00:04:06,140 --> 00:04:08,390
Actually, I have copied entire section.

48
00:04:08,390 --> 00:04:13,910
Let me remove this part and leave only IP address in place like so.

49
00:04:14,240 --> 00:04:14,780
Great.

50
00:04:14,780 --> 00:04:17,450
And next, let's specify name of the image.

51
00:04:17,450 --> 00:04:23,240
It will be same as before phpMyAdmin slash phpMyAdmin.

52
00:04:23,270 --> 00:04:25,250
Don't forget to add here slash.

53
00:04:25,250 --> 00:04:30,140
Otherwise you will be able to create container because there is no image called phpMyAdmin.

54
00:04:30,350 --> 00:04:30,830
Great.

55
00:04:30,860 --> 00:04:31,940
Let's press enter.

56
00:04:32,700 --> 00:04:39,030
And meanwhile, let's go back to Google Chrome and to this page where we have started connection to

57
00:04:39,330 --> 00:04:45,660
phpMyAdmin recap that now we have created a brand new container and now it has an environment variable

58
00:04:45,660 --> 00:04:46,200
set.

59
00:04:46,230 --> 00:04:54,060
Let's go to this same address and here let's now try to connect to MySQL server using root username

60
00:04:54,060 --> 00:04:57,510
and password will be my dash password.

61
00:04:58,630 --> 00:05:05,890
Again, this password I take from this line that we have used for start of the MySQL server, it is

62
00:05:05,890 --> 00:05:09,670
MySQL root password that is in my case set to my password.

63
00:05:09,670 --> 00:05:13,960
If you used another password, please use your password on this page.

64
00:05:13,960 --> 00:05:15,640
And now let's click go.

65
00:05:16,660 --> 00:05:21,670
And we have successfully logged into MySQL database.

66
00:05:21,910 --> 00:05:24,530
You are able to browse databases.

67
00:05:24,550 --> 00:05:30,470
You see such databases as information schema, MySQL performance schema, Sis and so on.

68
00:05:30,490 --> 00:05:36,340
You are able to create new databases if you want to, but the main idea is that we have successfully

69
00:05:36,340 --> 00:05:45,220
connected to MySQL server MySQL container from the phpMyAdmin container using IP address of the MySQL

70
00:05:45,220 --> 00:05:45,880
server.

71
00:05:46,210 --> 00:05:54,340
Let's go back to terminal and verify quickly which environment variables were set for phpMyAdmin container.

72
00:05:54,370 --> 00:06:02,830
Let's clear a terminal here and let's list containers Docker and let's use Docker Exec and here will

73
00:06:02,830 --> 00:06:05,470
be the ID of the phpMyAdmin container.

74
00:06:05,470 --> 00:06:09,160
This 18A and here let's type env.

75
00:06:09,190 --> 00:06:16,690
We want to list environment variables for this specific container and here is a long list of variables

76
00:06:16,790 --> 00:06:26,420
that were set for this phpmyadmin container like version url php version because actually this container

77
00:06:26,420 --> 00:06:27,500
is running php.

78
00:06:27,830 --> 00:06:32,750
Also, if I'll scroll up you should see environment variable that was set.

79
00:06:32,750 --> 00:06:33,650
Customly.

80
00:06:33,650 --> 00:06:36,860
Where it is, I cannot find it.

81
00:06:37,100 --> 00:06:37,760
Sorry.

82
00:06:37,760 --> 00:06:45,680
This one underscore host and here in this environment variable we have set IP address of the mysql server,

83
00:06:46,010 --> 00:06:52,940
but could you please point me to drawback of usage of such environment variable where we have used the

84
00:06:52,970 --> 00:06:53,960
IP address?

85
00:06:57,600 --> 00:06:58,920
Yes, you are right.

86
00:06:58,960 --> 00:07:02,460
IP address of the MySQL server may change.

87
00:07:02,460 --> 00:07:09,780
And actually I have told you before that Docker host assigns IP address to containers in random fashion.

88
00:07:09,780 --> 00:07:12,510
Actually starts from the address zero two.

89
00:07:12,510 --> 00:07:19,920
But if I'll start MySQL container once again or if I'll start new container using MySQL, it will get

90
00:07:19,920 --> 00:07:27,750
brand new IP address and in such case, phpMyAdmin will not be able to connect to that container because

91
00:07:27,750 --> 00:07:29,790
it will have another IP address.

92
00:07:29,790 --> 00:07:30,480
That's why.

93
00:07:30,510 --> 00:07:34,260
Preferable way of connection between different servers.

94
00:07:34,260 --> 00:07:39,690
It is actually general recommendation not just related to Docker is to use hostnames.

95
00:07:40,420 --> 00:07:42,790
But how we're able to use host names here.

96
00:07:42,790 --> 00:07:48,580
In this case, basically now every container has specific random name here.

97
00:07:48,580 --> 00:07:55,780
You are able to list those names, Docker, PS, you'll find this random name for this container or

98
00:07:55,780 --> 00:07:58,390
this random name for another container.

99
00:07:58,750 --> 00:08:06,400
Question Do we able to use those random names as host names for communication between different containers?

100
00:08:07,090 --> 00:08:09,610
Let me answer this question in the next lecture.

101
00:08:09,610 --> 00:08:15,850
But for now, let's summarize that we were able to create two different containers and actually link

102
00:08:15,850 --> 00:08:22,390
them together, and we were able to connect from phpMyAdmin container to MySQL container.

103
00:08:22,390 --> 00:08:28,840
And here you'll see actually this management page where you are able to manage MySQL database located

104
00:08:28,840 --> 00:08:30,160
at this IP address.

105
00:08:30,160 --> 00:08:32,710
172 1702.

106
00:08:33,360 --> 00:08:34,620
That's all for this lecture.

107
00:08:34,620 --> 00:08:42,240
And next, let's try to explore how we are able to connect different containers over hostnames instead

108
00:08:42,240 --> 00:08:43,380
of IP addresses.

109
00:08:43,470 --> 00:08:44,870
I'll see you in the next lecture.

110
00:08:44,880 --> 00:08:45,480
Bye bye.

