1
00:00:04,030 --> 00:00:04,660
Alright.

2
00:00:04,689 --> 00:00:10,600
We have just removed the all containers that were stopped before and if I type now, Docker PS dash

3
00:00:10,600 --> 00:00:16,510
A, you'll see empty output and if you have not cleaned your containers, please watch the previous

4
00:00:16,510 --> 00:00:17,170
lecture.

5
00:00:17,170 --> 00:00:21,280
In this lecture, let's create a container based on Python image.

6
00:00:21,280 --> 00:00:24,970
And for that let's first pull Python image from Docker Hub.

7
00:00:25,090 --> 00:00:28,060
Docker pull Python.

8
00:00:28,240 --> 00:00:30,550
And I don't specify any tag.

9
00:00:30,550 --> 00:00:34,810
It means that latest version of Python image will be pulled.

10
00:00:35,140 --> 00:00:42,520
Notice that now we are downloading basically multiple file system layers and they are relatively large

11
00:00:42,520 --> 00:00:43,120
in comparison.

12
00:00:43,120 --> 00:00:46,450
For example to Alpine or ubuntu image.

13
00:00:46,540 --> 00:00:47,650
Let's wait a bit.

14
00:00:47,680 --> 00:00:53,890
Actually from this output you see that we have actually pulled compressed layers and afterwards locally

15
00:00:53,890 --> 00:00:57,610
we extract contents from that compressed layers.

16
00:00:57,820 --> 00:01:06,680
Wonderful image was pulled and here is its Sha 256 hash and you see that we have downloaded python latest

17
00:01:06,680 --> 00:01:08,690
image latest is its tag.

18
00:01:08,780 --> 00:01:09,350
Great.

19
00:01:09,350 --> 00:01:16,820
Let's now verify list of images Docker images and you'll see here Python on the list and its size is

20
00:01:16,820 --> 00:01:18,500
around one gigabyte.

21
00:01:18,530 --> 00:01:25,700
It is really, really huge in comparison to other images like nginx, alpine or ubuntu.

22
00:01:25,730 --> 00:01:26,570
Wonderful.

23
00:01:26,570 --> 00:01:32,870
Let's now try to create container based on this python image and let's simply use docker run command

24
00:01:32,870 --> 00:01:35,030
with name of the image python.

25
00:01:35,030 --> 00:01:38,510
Let's clear terminal docker run python.

26
00:01:40,550 --> 00:01:46,340
And as before, we see that container was basically created under the hood, but it was immediately

27
00:01:46,340 --> 00:01:47,160
terminated.

28
00:01:47,180 --> 00:01:54,140
Let's list here containers, Docker, PS And you see no containers currently running, but there is

29
00:01:54,140 --> 00:01:58,730
a single container here in the history and it was exited 14 seconds ago.

30
00:01:58,730 --> 00:02:01,430
And you see here command that was executed.

31
00:02:01,430 --> 00:02:07,060
It was Python three, but we have not connected to standard in of this process.

32
00:02:07,070 --> 00:02:12,890
This process was exited therefore and afterwards container was terminated by Docker because there were

33
00:02:12,890 --> 00:02:14,660
no processes running.

34
00:02:14,990 --> 00:02:20,930
Again, situation is the same as we have seen, for example with Alpine or Ubuntu containers.

35
00:02:20,930 --> 00:02:27,530
If you don't connect to standard input of specific process, process exits automatically and Docker

36
00:02:27,530 --> 00:02:29,390
stops such container.

37
00:02:29,600 --> 00:02:30,170
Great.

38
00:02:30,170 --> 00:02:34,370
Let me now clear terminal and run this container with options.

39
00:02:34,370 --> 00:02:38,810
Dash i and dash t docker run dash it.

40
00:02:38,960 --> 00:02:43,080
I can combine those two options and here will be python like so.

41
00:02:43,560 --> 00:02:48,570
And now you see that we have actually opened interactive session with Python.

42
00:02:48,570 --> 00:02:54,720
Actually the same happens when Python is installed locally on your computer and when you enter Python

43
00:02:54,720 --> 00:02:56,280
three or Python command.

44
00:02:56,310 --> 00:02:59,390
We are now inside of the interactive shell with Python.

45
00:02:59,400 --> 00:03:02,130
Let's now, for example, enter help here.

46
00:03:02,580 --> 00:03:07,500
Actually, in order to get interactive help, I need to add parentheses here like so and you'll see

47
00:03:07,530 --> 00:03:08,040
message.

48
00:03:08,040 --> 00:03:15,540
Welcome to Python 3.8 and here you see that you are able to explore help for different modules, keywords

49
00:03:15,540 --> 00:03:17,520
or symbols like you see here.

50
00:03:17,520 --> 00:03:22,440
And for example, we are able to get list of Python modules by entering modules.

51
00:03:23,490 --> 00:03:27,690
And afterwards you are able to get help about any of those modules.

52
00:03:27,690 --> 00:03:33,630
And let's, for example, get help about the Lib module and for that simply type name of corresponding

53
00:03:33,630 --> 00:03:41,370
module here, zlib like so, and you'll get module reference here and you may read about this module,

54
00:03:41,370 --> 00:03:43,260
what it does and how it is used.

55
00:03:43,260 --> 00:03:44,790
Actually great.

56
00:03:44,790 --> 00:03:48,210
That's how you able to get help inside of this interactive session.

57
00:03:48,210 --> 00:03:53,430
And if you want to exit from here, you could simply press Q and press enter.

58
00:03:53,430 --> 00:03:57,810
And afterwards here you are able to execute any Python commands.

59
00:03:57,810 --> 00:04:08,910
For example, let's type three plus seven, I get ten, let's print hello from Python like so and I

60
00:04:08,910 --> 00:04:10,620
get Hello from Python here.

61
00:04:10,650 --> 00:04:15,060
That's how you able to interact with Python interpreter okay.

62
00:04:15,060 --> 00:04:20,269
Also notice that this container is still up and running because we are now connected to standard in

63
00:04:20,279 --> 00:04:24,940
and standard output of specific process, namely Python three process.

64
00:04:24,940 --> 00:04:32,740
And if I open new tab and list containers here, Docker PS you see that the Python image was used for

65
00:04:32,740 --> 00:04:36,880
creation of this container with container ID, this one and the random name.

66
00:04:36,880 --> 00:04:42,730
This one was assigned to this container and here you see command that was automatically executed.

67
00:04:42,730 --> 00:04:43,930
Python three.

68
00:04:44,470 --> 00:04:49,930
All right, Let's now go back to this step and let's exit from this interactive session.

69
00:04:49,930 --> 00:04:53,650
And for that you could type exit with parentheses like so.

70
00:04:54,870 --> 00:04:58,510
Process was terminated and container was stopped as well.

71
00:04:58,530 --> 00:04:59,880
Let's verify that.

72
00:04:59,910 --> 00:05:06,420
Docker PS And yes, there are no running containers, but this container is listed here.

73
00:05:06,420 --> 00:05:09,750
If I add a option, all great.

74
00:05:09,750 --> 00:05:16,560
That's how we were able to create the python container and run some code inside of that container.

75
00:05:16,560 --> 00:05:22,170
But of course, in practice during development usually you need to have a python container in order

76
00:05:22,170 --> 00:05:25,200
to execute your python applications.

77
00:05:25,200 --> 00:05:31,200
And next, let me demonstrate you how you are able to run your specific project located on your local

78
00:05:31,200 --> 00:05:33,430
computer using Python container.

79
00:05:33,450 --> 00:05:34,500
Let's do that next.

80
00:05:34,500 --> 00:05:35,070
Bye bye.

