1
00:00:00,000 --> 00:00:01,080
In this lesson,

2
00:00:01,080 --> 00:00:03,183
we're going to cover some basic container operations

3
00:00:03,183 --> 00:00:05,910
that you should be aware of to manage your containers

4
00:00:05,910 --> 00:00:08,760
and conduct basic container image operations.

5
00:00:08,760 --> 00:00:12,180
First, let's jump into our container image operations.

6
00:00:12,180 --> 00:00:13,740
To work with a container image,

7
00:00:13,740 --> 00:00:16,260
you can use a program like Docker or Podman

8
00:00:16,260 --> 00:00:19,830
to run a manage containers and container images.

9
00:00:19,830 --> 00:00:22,080
Now, Podman is a containerization program

10
00:00:22,080 --> 00:00:24,180
that runs on Red Hat Enterprise Linux,

11
00:00:24,180 --> 00:00:26,040
and supports just about all the features

12
00:00:26,040 --> 00:00:27,480
you're going to find in Docker,

13
00:00:27,480 --> 00:00:29,820
without needing the underlying Docker service

14
00:00:29,820 --> 00:00:32,460
or an active container engine on your system.

15
00:00:32,460 --> 00:00:34,140
When it comes to issuing commands,

16
00:00:34,140 --> 00:00:37,380
the same syntax is used for both Docker and Podman,

17
00:00:37,380 --> 00:00:39,300
so you can choose which one you prefer to use,

18
00:00:39,300 --> 00:00:41,400
and the commands that I'm going to cover in this lesson

19
00:00:41,400 --> 00:00:44,070
are going to work equally well with both of them.

20
00:00:44,070 --> 00:00:46,530
When you're performing container image operations,

21
00:00:46,530 --> 00:00:49,200
you need to understand how to do some basic functions,

22
00:00:49,200 --> 00:00:51,780
things like building, pushing, pulling,

23
00:00:51,780 --> 00:00:54,510
listing and removing container images.

24
00:00:54,510 --> 00:00:55,830
To build a container image,

25
00:00:55,830 --> 00:00:58,500
you're going to issue the command podman build.

26
00:00:58,500 --> 00:00:59,850
And this will build a container image

27
00:00:59,850 --> 00:01:01,800
using a Docker file instruction

28
00:01:01,800 --> 00:01:03,960
that's located in the current directory.

29
00:01:03,960 --> 00:01:06,750
To push a container image to a specified destination,

30
00:01:06,750 --> 00:01:09,480
you're going to enter the command podman push.

31
00:01:09,480 --> 00:01:12,330
This destination could be any container management service

32
00:01:12,330 --> 00:01:15,540
that you're going to use, such as Docker or Kubernetes.

33
00:01:15,540 --> 00:01:18,120
To pull a container image from a container registry,

34
00:01:18,120 --> 00:01:20,790
you're going to enter the command podman pull.

35
00:01:20,790 --> 00:01:23,910
This registry could be a public or private registry,

36
00:01:23,910 --> 00:01:25,950
as long as you have the proper access rights

37
00:01:25,950 --> 00:01:29,010
and network productivity to that given registry.

38
00:01:29,010 --> 00:01:30,870
To list out the container images available

39
00:01:30,870 --> 00:01:32,670
on your local system, you can do this

40
00:01:32,670 --> 00:01:35,340
by entering the command podman images.

41
00:01:35,340 --> 00:01:37,200
If you want to list out all of the running containers,

42
00:01:37,200 --> 00:01:39,450
on the other hand, you can enter podman ps -a

43
00:01:40,860 --> 00:01:44,010
to list out all the running containers on your screen.

44
00:01:44,010 --> 00:01:46,590
If you want to remove a container image, you can do this

45
00:01:46,590 --> 00:01:50,460
by entering the command pod man rmi and the image ID.

46
00:01:50,460 --> 00:01:51,990
This will then remove the container image

47
00:01:51,990 --> 00:01:53,370
from the current list of containers

48
00:01:53,370 --> 00:01:55,110
available on your system.

49
00:01:55,110 --> 00:01:58,440
Now, as a reminder, all the podman commands that I went over

50
00:01:58,440 --> 00:02:00,930
are just a subset of the long list of commands

51
00:02:00,930 --> 00:02:02,790
that you can use to work with containers,

52
00:02:02,790 --> 00:02:04,620
depending on your use case.

53
00:02:04,620 --> 00:02:06,150
To learn more about Podman,

54
00:02:06,150 --> 00:02:09,270
you can always check the man pages on your Linux system.

55
00:02:09,270 --> 00:02:11,250
Also, remember that Podman uses

56
00:02:11,250 --> 00:02:13,530
the exact same syntax as Docker,

57
00:02:13,530 --> 00:02:15,660
and so you can easily replace the word podman

58
00:02:15,660 --> 00:02:17,730
with the word Docker and all these commands

59
00:02:17,730 --> 00:02:20,760
we just discussed will work inside of Docker, too.

60
00:02:20,760 --> 00:02:23,040
Next, let's talk about container management

61
00:02:23,040 --> 00:02:25,740
and how you can perform some basic container operations,

62
00:02:25,740 --> 00:02:27,660
like starting and stopping containers,

63
00:02:27,660 --> 00:02:30,240
inspecting containers, listing containers,

64
00:02:30,240 --> 00:02:33,390
deploying existing images, connecting to containers,

65
00:02:33,390 --> 00:02:35,370
logging actions inside of containers

66
00:02:35,370 --> 00:02:37,800
and exposing ports for your containers.

67
00:02:37,800 --> 00:02:40,890
First, we have the starting and stopping of containers.

68
00:02:40,890 --> 00:02:43,879
If you want to start a container, simply enter the command

69
00:02:43,879 --> 00:02:46,020
podman start, and the name of the container image

70
00:02:46,020 --> 00:02:47,370
that you want to start.

71
00:02:47,370 --> 00:02:50,610
If you want to stop a container, simply enter podman stop,

72
00:02:50,610 --> 00:02:53,280
and the name of the container image that you want to stop.

73
00:02:53,280 --> 00:02:55,830
Second, we have inspecting containers.

74
00:02:55,830 --> 00:02:57,739
Now, to inspect a container, you simply enter

75
00:02:57,739 --> 00:03:01,290
podman inspect, and the name of the container image.

76
00:03:01,290 --> 00:03:02,940
This will then display the configuration

77
00:03:02,940 --> 00:03:04,590
of a given container or image

78
00:03:04,590 --> 00:03:06,240
so that you can ensure it's properly set up

79
00:03:06,240 --> 00:03:08,790
and configured for your particular use case.

80
00:03:08,790 --> 00:03:11,070
Third, we have listing containers.

81
00:03:11,070 --> 00:03:13,260
To list out all the containers on your system,

82
00:03:13,260 --> 00:03:15,750
you can use podman pod list

83
00:03:15,750 --> 00:03:17,370
and this is going to show the containers,

84
00:03:17,370 --> 00:03:19,890
their current status, such as running or paused,

85
00:03:19,890 --> 00:03:21,870
and when they were first created.

86
00:03:21,870 --> 00:03:24,720
Fourth, we have deploying existing images.

87
00:03:24,720 --> 00:03:27,300
Now, the best way to deploy an image is to use a template

88
00:03:27,300 --> 00:03:29,610
in order to give your users a quick and easy way

89
00:03:29,610 --> 00:03:32,430
to deploy an image with a working configuration.

90
00:03:32,430 --> 00:03:34,020
A template file is going to be created

91
00:03:34,020 --> 00:03:36,240
based on the format of the containerization solution

92
00:03:36,240 --> 00:03:39,570
that you're going to be using, such as OpenShift or Kubernetes.

93
00:03:39,570 --> 00:03:42,000
And this will include a unique user-friendly name,

94
00:03:42,000 --> 00:03:43,710
as well as descriptions of the containers

95
00:03:43,710 --> 00:03:46,500
and the pods that are being used by that image.

96
00:03:46,500 --> 00:03:48,870
Fifth, we have connecting to containers.

97
00:03:48,870 --> 00:03:51,750
Now, if you want to connect to a container to interact with it

98
00:03:51,750 --> 00:03:54,090
you can use the podman attach command

99
00:03:54,090 --> 00:03:56,010
and then the container's image name.

100
00:03:56,010 --> 00:03:57,450
This will attach your console

101
00:03:57,450 --> 00:04:00,150
to a running container based on its name or ID

102
00:04:00,150 --> 00:04:02,520
and then allow you to view its ongoing output

103
00:04:02,520 --> 00:04:05,850
or interactively take control of that container.

104
00:04:05,850 --> 00:04:08,700
Sixth, we have logging actions and containers.

105
00:04:08,700 --> 00:04:10,050
Now, inside of your containers

106
00:04:10,050 --> 00:04:12,030
there is logging that's happening by default,

107
00:04:12,030 --> 00:04:13,770
but you have to get those logs

108
00:04:13,770 --> 00:04:15,750
from the container to be able to read them.

109
00:04:15,750 --> 00:04:17,550
To gather the logs from a container,

110
00:04:17,550 --> 00:04:20,490
you can enter podman logs and the container's name

111
00:04:20,490 --> 00:04:22,590
to view and collect those logs.

112
00:04:22,590 --> 00:04:25,680
Seventh, we have exposing ports for your containers.

113
00:04:25,680 --> 00:04:28,710
Now, if you enter podman port and the container name,

114
00:04:28,710 --> 00:04:30,690
you're going to see a list of all the port mappings

115
00:04:30,690 --> 00:04:32,160
for a given container.

116
00:04:32,160 --> 00:04:33,960
To expose a port on a container,

117
00:04:33,960 --> 00:04:36,180
you can do this when you initially create that container

118
00:04:36,180 --> 00:04:38,010
using the podman create command

119
00:04:38,010 --> 00:04:41,190
and using the --expose=port option

120
00:04:41,190 --> 00:04:43,890
where the port contains the port number or port numbers

121
00:04:43,890 --> 00:04:46,950
that you want to expose to redirection by that host system.

122
00:04:46,950 --> 00:04:48,630
If you want to expose a port on a container

123
00:04:48,630 --> 00:04:50,400
when you start it up or you run it,

124
00:04:50,400 --> 00:04:55,140
you can instead enter podman run --expose=port.

125
00:04:55,140 --> 00:04:57,780
Now, for the exam, you do not have to be an expert

126
00:04:57,780 --> 00:04:59,760
in conducting container operations,

127
00:04:59,760 --> 00:05:01,350
but you should understand the basics

128
00:05:01,350 --> 00:05:02,940
that we covered in this lesson.

129
00:05:02,940 --> 00:05:05,160
For example, if I asked you how to download

130
00:05:05,160 --> 00:05:08,310
a container image from a container registry using Podman,

131
00:05:08,310 --> 00:05:10,050
you should select the answer that contains

132
00:05:10,050 --> 00:05:12,420
the podman pull command, because this is used

133
00:05:12,420 --> 00:05:15,180
to pull or download an image from a registry.

134
00:05:15,180 --> 00:05:17,100
This is the level of depth that you need to have

135
00:05:17,100 --> 00:05:19,050
in order to answer questions on the exam

136
00:05:19,050 --> 00:05:21,003
about basic container operations.

