1
00:00:02,180 --> 00:00:04,090
So now, we're going to repeat

2
00:00:04,090 --> 00:00:06,740
the deployment example from before,

3
00:00:06,740 --> 00:00:09,770
but now not with AWS EC2,

4
00:00:09,770 --> 00:00:12,000
where we need to manage on our own,

5
00:00:12,000 --> 00:00:15,390
but with another service, which we can find by clicking

6
00:00:15,390 --> 00:00:17,280
on that service's dropdown here,

7
00:00:17,280 --> 00:00:19,220
and then searching for ECS,

8
00:00:19,220 --> 00:00:21,910
which is this Elastic Container Service.

9
00:00:21,910 --> 00:00:24,300
That's what we're going to use now.

10
00:00:24,300 --> 00:00:27,480
And now, I have one important disclaimer here.

11
00:00:27,480 --> 00:00:31,380
Where EC2, the way we used it at least,

12
00:00:31,380 --> 00:00:34,030
was covered by that free tier,

13
00:00:34,030 --> 00:00:37,060
the services we're using now and over the next lectures

14
00:00:37,060 --> 00:00:39,150
might not be covered.

15
00:00:39,150 --> 00:00:41,700
So if you wanna avoid any costs,

16
00:00:41,700 --> 00:00:45,130
you definitely should follow along passively here

17
00:00:45,130 --> 00:00:48,780
and/or check the AWS pricing pages

18
00:00:48,780 --> 00:00:52,430
to find out which costs you might incur.

19
00:00:52,430 --> 00:00:56,620
Now, we're only going to use the minimal set of features,

20
00:00:56,620 --> 00:00:59,390
so potential costs shouldn't be high,

21
00:00:59,390 --> 00:01:01,810
but I still wanna emphasize it here

22
00:01:01,810 --> 00:01:06,220
so that you don't blame me if your credit card gets charged.

23
00:01:06,220 --> 00:01:07,840
It's a cloud service provider.

24
00:01:07,840 --> 00:01:10,280
They earn money by selling services,

25
00:01:10,280 --> 00:01:13,030
and therefore, of course, not everything is free.

26
00:01:13,030 --> 00:01:14,830
That's just a disclaimer here.

27
00:01:14,830 --> 00:01:16,780
And just to also make this clear,

28
00:01:16,780 --> 00:01:18,660
we would have the same problem

29
00:01:18,660 --> 00:01:20,800
with basically any provider

30
00:01:20,800 --> 00:01:24,620
because ultimately some services will cost money.

31
00:01:24,620 --> 00:01:25,850
So with that out of the way,

32
00:01:25,850 --> 00:01:27,983
let's dive in and use that service though.

33
00:01:29,120 --> 00:01:32,620
And here, you should see some getting started screen,

34
00:01:32,620 --> 00:01:35,920
which might look slightly different after some time,

35
00:01:35,920 --> 00:01:38,650
but in the end, you should have some getting started screen

36
00:01:38,650 --> 00:01:40,820
with a get started button.

37
00:01:40,820 --> 00:01:44,720
Press that button, and you should see something like this.

38
00:01:44,720 --> 00:01:46,990
That's the wizard you will see

39
00:01:46,990 --> 00:01:51,560
when you launch your first container with ECS.

40
00:01:51,560 --> 00:01:54,150
Now, the container we are going to launch

41
00:01:54,150 --> 00:01:57,340
is that node-example-1 container,

42
00:01:57,340 --> 00:02:00,550
which I pushed to Docker Hub before

43
00:02:00,550 --> 00:02:02,450
in the last lectures.

44
00:02:02,450 --> 00:02:04,850
So if you skipped these lectures,

45
00:02:04,850 --> 00:02:08,930
make sure you take the example project you find attached,

46
00:02:08,930 --> 00:02:11,480
build an image from that project,

47
00:02:11,480 --> 00:02:14,850
and push that image to your Docker Hub account,

48
00:02:14,850 --> 00:02:16,310
and then use that image

49
00:02:16,310 --> 00:02:20,000
because this specific image on my Docker Hub account

50
00:02:20,000 --> 00:02:23,453
will not be available anymore when you're watching this.

51
00:02:24,410 --> 00:02:26,660
For me, right now, it is available though,

52
00:02:26,660 --> 00:02:29,470
and that's the image which we'll now deploy

53
00:02:29,470 --> 00:02:31,380
with help of ECS.

54
00:02:31,380 --> 00:02:33,587
So how does this work then?

55
00:02:33,587 --> 00:02:38,587
AWS ECS thinks in four categories,

56
00:02:38,610 --> 00:02:42,600
clusters, containers, tasks, and services.

57
00:02:42,600 --> 00:02:44,730
Now, it should be clear what containers are,

58
00:02:44,730 --> 00:02:46,850
and that's what we're going to start with.

59
00:02:46,850 --> 00:02:48,410
Initially in that wizard,

60
00:02:48,410 --> 00:02:51,090
we pick the container we wanna deploy.

61
00:02:51,090 --> 00:02:53,450
Now, there are some examples here,

62
00:02:53,450 --> 00:02:56,220
but we're going to go with our own custom container.

63
00:02:56,220 --> 00:02:58,050
So we should click on Configure here,

64
00:02:58,050 --> 00:03:01,020
and this opens up this side drawer

65
00:03:01,020 --> 00:03:04,093
where we can now define our own custom container.

66
00:03:04,940 --> 00:03:06,900
Now, we should give this container a name,

67
00:03:06,900 --> 00:03:09,890
and I'll choose node-demo here,

68
00:03:09,890 --> 00:03:12,320
and then we have to define the image

69
00:03:12,320 --> 00:03:14,730
on which this container should be based.

70
00:03:14,730 --> 00:03:16,800
And before we do that,

71
00:03:16,800 --> 00:03:20,840
I have one important note about this side drawer.

72
00:03:20,840 --> 00:03:23,800
In the end here, we just specify

73
00:03:23,800 --> 00:03:28,493
how ECS should later execute docker run.

74
00:03:29,500 --> 00:03:31,840
You will see plenty of options here,

75
00:03:31,840 --> 00:03:36,470
which you could also just plug into your docker run command.

76
00:03:36,470 --> 00:03:41,039
For example, --name for the container name.

77
00:03:41,039 --> 00:03:43,990
And the image is, of course, also the required

78
00:03:43,990 --> 00:03:47,073
for docker run, so we also need to define it here.

79
00:03:47,948 --> 00:03:50,940
In here, you should take your repository name.

80
00:03:50,940 --> 00:03:54,783
In my case, it's academind/node-example-1.

81
00:03:55,770 --> 00:03:58,510
And if your image is on Docker Hub,

82
00:03:58,510 --> 00:04:01,370
you just need to enter this repository name,

83
00:04:01,370 --> 00:04:05,690
and ECS will automatically look on Docker Hub.

84
00:04:05,690 --> 00:04:08,650
If you're using some other container registry,

85
00:04:08,650 --> 00:04:13,650
you need to have the full registry hosting domain here,

86
00:04:13,800 --> 00:04:16,230
and then the repository name.

87
00:04:16,230 --> 00:04:20,360
But for Docker Hub, just the repository name is enough.

88
00:04:20,360 --> 00:04:22,750
Now, if it should be a private repository,

89
00:04:22,750 --> 00:04:26,170
you can specify your login information here,

90
00:04:26,170 --> 00:04:29,380
but it's not a private repository here.

91
00:04:29,380 --> 00:04:32,220
You can leave the default for the memory limits,

92
00:04:32,220 --> 00:04:34,910
but of course we wanna map some ports.

93
00:04:34,910 --> 00:04:37,980
Again, in the end here, in this overlay,

94
00:04:37,980 --> 00:04:42,530
we just define how docker run should be executed later.

95
00:04:42,530 --> 00:04:46,970
And if you run it locally, you also might specify a name,

96
00:04:46,970 --> 00:04:51,720
but we then, for this project, which listens on port 80,

97
00:04:51,720 --> 00:04:54,900
would definitely also publish port 80

98
00:04:54,900 --> 00:04:58,430
on the host machine with the -p flag.

99
00:04:58,430 --> 00:05:01,850
And that's just what we define here with port mappings.

100
00:05:01,850 --> 00:05:04,400
We want to expose port 80.

101
00:05:04,400 --> 00:05:07,810
Now, you don't need to specify two numbers here

102
00:05:07,810 --> 00:05:11,570
because the container internal port will always be mapped

103
00:05:11,570 --> 00:05:14,310
to the same port outside of the container.

104
00:05:14,310 --> 00:05:16,210
So this is automatically mapping

105
00:05:16,210 --> 00:05:19,913
the container internal port 80 to the outside port 80.

106
00:05:21,230 --> 00:05:25,510
Now, you can also configure advanced container options.

107
00:05:25,510 --> 00:05:27,830
Now, we can ignore the healthcheck for now.

108
00:05:27,830 --> 00:05:30,810
That's some AWS-specific setting

109
00:05:30,810 --> 00:05:33,700
which allows AWS to run a specific command

110
00:05:33,700 --> 00:05:37,280
to check whether the container is running successfully.

111
00:05:37,280 --> 00:05:38,900
We can ignore this here.

112
00:05:38,900 --> 00:05:41,530
But for the environment, we can, for example,

113
00:05:41,530 --> 00:05:45,000
override the default entry point or command

114
00:05:45,000 --> 00:05:48,618
that should be executed for this container when it starts.

115
00:05:48,618 --> 00:05:52,440
Again, that's also something you can do with docker run.

116
00:05:52,440 --> 00:05:56,470
You saw that in the utility containers section, for example.

117
00:05:56,470 --> 00:05:58,030
You can run a container

118
00:05:58,030 --> 00:06:01,740
and specify your own command that should be executed

119
00:06:01,740 --> 00:06:05,540
instead of the command specified in the Dockerfile.

120
00:06:05,540 --> 00:06:07,370
Here, however, I wanna go

121
00:06:07,370 --> 00:06:09,780
with the Dockerfile internal command,

122
00:06:09,780 --> 00:06:12,763
so I will not specify my own command.

123
00:06:13,620 --> 00:06:16,333
You could also override the working directory.

124
00:06:17,330 --> 00:06:19,260
And, again, even though that is nothing

125
00:06:19,260 --> 00:06:21,230
we've done thus far in the course,

126
00:06:21,230 --> 00:06:25,730
you indeed would have an option on docker run to do that.

127
00:06:25,730 --> 00:06:30,730
If we run docker run --help, we see all available options.

128
00:06:30,780 --> 00:06:34,000
And there, you see there is a workdir option

129
00:06:34,000 --> 00:06:37,120
which would allow you to override the working directory

130
00:06:37,120 --> 00:06:40,530
for this container when it's being started.

131
00:06:40,530 --> 00:06:42,870
And that's what you can set up here.

132
00:06:42,870 --> 00:06:44,680
Now, I wanna do none of that.

133
00:06:44,680 --> 00:06:48,240
I just wanna explain what you're configuring here.

134
00:06:48,240 --> 00:06:51,350
Now, if your container would be using environment variables,

135
00:06:51,350 --> 00:06:53,870
you probably would want to pass them in

136
00:06:53,870 --> 00:06:55,890
when the container runs.

137
00:06:55,890 --> 00:06:59,903
And locally, we did that with docker run --env.

138
00:07:01,190 --> 00:07:02,730
Now here, we can define

139
00:07:02,730 --> 00:07:05,790
our environment variable key value pairs

140
00:07:05,790 --> 00:07:10,403
simply here in this part of that AWS console.

141
00:07:12,090 --> 00:07:14,420
Now, we can also define container timeouts,

142
00:07:14,420 --> 00:07:18,570
so basically telling AWS when it should stop trying

143
00:07:18,570 --> 00:07:20,280
to launch this container.

144
00:07:20,280 --> 00:07:22,380
We can set up network settings,

145
00:07:22,380 --> 00:07:23,790
and I'll come back to that later

146
00:07:23,790 --> 00:07:26,560
once we have more than one container being deployed.

147
00:07:26,560 --> 00:07:28,920
For the moment, we can ignore all of that.

148
00:07:28,920 --> 00:07:32,980
By default, our container will be reachable from the web.

149
00:07:32,980 --> 00:07:34,760
I can tell you that.

150
00:07:34,760 --> 00:07:37,030
Unless you disable networking, of course,

151
00:07:37,030 --> 00:07:38,480
which we don't wanna do here.

152
00:07:38,480 --> 00:07:40,550
We wanna keep it enabled.

153
00:07:40,550 --> 00:07:42,020
Under storage and logging,

154
00:07:42,020 --> 00:07:45,180
you can define mount points and volumes.

155
00:07:45,180 --> 00:07:48,290
Again, that's not something we use right now,

156
00:07:48,290 --> 00:07:51,290
but I will come back to that later as well.

157
00:07:51,290 --> 00:07:54,820
And, of course, that is the equivalent to the -v option

158
00:07:54,820 --> 00:07:56,043
on docker run.

159
00:07:57,710 --> 00:08:01,150
Then, you can configure logging if you want to.

160
00:08:01,150 --> 00:08:04,230
And, with Auto-configure CloudWatch Logs,

161
00:08:04,230 --> 00:08:09,160
you automatically use another AWS service called CloudWatch

162
00:08:09,160 --> 00:08:13,120
to manage and store the logs generated by this container,

163
00:08:13,120 --> 00:08:15,680
which could be useful, so I'll do that here,

164
00:08:15,680 --> 00:08:17,760
but you don't have to check it.

165
00:08:17,760 --> 00:08:19,730
And that is basically it.

166
00:08:19,730 --> 00:08:23,030
Now with that, we can click Update here,

167
00:08:23,030 --> 00:08:26,003
and now we configured our container

168
00:08:26,003 --> 00:08:28,560
that should be launched here.

169
00:08:28,560 --> 00:08:29,810
Now, in case you're wondering

170
00:08:29,810 --> 00:08:32,480
how you could launch multiple containers,

171
00:08:32,480 --> 00:08:33,520
I'll come back to that.

172
00:08:33,520 --> 00:08:34,352
For the moment,

173
00:08:34,352 --> 00:08:37,063
let's stick to this single container example.

174
00:08:38,940 --> 00:08:42,210
Now, in the next section, we can define our task

175
00:08:42,210 --> 00:08:43,470
for this container.

176
00:08:43,470 --> 00:08:46,640
And the task is basically, as it says here,

177
00:08:46,640 --> 00:08:48,930
the blueprint for your application.

178
00:08:48,930 --> 00:08:52,950
Here, you can tell AWS how it should launch your container.

179
00:08:52,950 --> 00:08:55,420
So not how it should execute docker run,

180
00:08:55,420 --> 00:08:58,070
but how the server on which it runs this

181
00:08:58,070 --> 00:09:00,680
should be configured, you could say.

182
00:09:00,680 --> 00:09:04,040
And therefore a task actually also can include

183
00:09:04,040 --> 00:09:07,320
more than one container, and you will also see that later

184
00:09:07,320 --> 00:09:11,020
when we add multiple containers to one and the same task.

185
00:09:11,020 --> 00:09:15,460
So you can think of the task as one remote server,

186
00:09:15,460 --> 00:09:19,860
one remote machine, which runs one or more containers.

187
00:09:19,860 --> 00:09:23,690
So a bit like the EC2 instances you saw before,

188
00:09:23,690 --> 00:09:25,680
which we managed ourself.

189
00:09:25,680 --> 00:09:27,870
Now, we're not managing it ourself,

190
00:09:27,870 --> 00:09:30,140
but we're still telling AWS

191
00:09:30,140 --> 00:09:32,300
how it should execute our containers,

192
00:09:32,300 --> 00:09:35,750
and which environment it should generally set up for them.

193
00:09:35,750 --> 00:09:37,810
And that's what a task is.

194
00:09:37,810 --> 00:09:41,440
And here, we're using FARGATE by default.

195
00:09:41,440 --> 00:09:44,490
That's a specific way of launching your container,

196
00:09:44,490 --> 00:09:48,940
which in the end launches it in a so-called serverless mode,

197
00:09:48,940 --> 00:09:53,930
which means AWS does not really create an EC2 instance

198
00:09:53,930 --> 00:09:55,790
on which it runs your container,

199
00:09:55,790 --> 00:09:59,830
but instead it stores your container and your run settings,

200
00:09:59,830 --> 00:10:01,860
and whenever there is a request

201
00:10:01,860 --> 00:10:05,460
that requires the container to do something,

202
00:10:05,460 --> 00:10:08,890
it starts the container up, handles that request,

203
00:10:08,890 --> 00:10:10,450
and then stops it again,

204
00:10:10,450 --> 00:10:12,880
which is, of course, very cost effective

205
00:10:12,880 --> 00:10:14,670
because you only pay

206
00:10:14,670 --> 00:10:17,420
for the time your container is executing

207
00:10:17,420 --> 00:10:20,893
and not for the time where it's just sitting around idle.

208
00:10:21,820 --> 00:10:23,910
So that's why we're using FARGATE here,

209
00:10:23,910 --> 00:10:27,310
this serverless container launching mode.

210
00:10:27,310 --> 00:10:30,090
And then, we can click Next.

211
00:10:30,090 --> 00:10:32,830
Now here, we define our service.

212
00:10:32,830 --> 00:10:37,480
And a service, in the end, now controls how this task,

213
00:10:37,480 --> 00:10:40,650
so this configured application and the container

214
00:10:40,650 --> 00:10:44,185
that belongs to it, should be executed.

215
00:10:44,185 --> 00:10:47,480
And it's here where you, for example,

216
00:10:47,480 --> 00:10:49,810
could add a load balancer,

217
00:10:49,810 --> 00:10:52,410
and it manages all the heavy lifting

218
00:10:52,410 --> 00:10:55,200
of redirecting the incoming requests,

219
00:10:55,200 --> 00:10:57,160
queue the up and running containers,

220
00:10:57,160 --> 00:11:00,040
and all of that behind the scenes.

221
00:11:00,040 --> 00:11:02,780
Now, I'm not going to use a load balancer here,

222
00:11:02,780 --> 00:11:05,400
but we will add one later in this module.

223
00:11:05,400 --> 00:11:09,170
To keep things simple for now, we'll start without one.

224
00:11:09,170 --> 00:11:13,280
So you could say every task is executed by a service.

225
00:11:13,280 --> 00:11:15,500
So you have one service per task.

226
00:11:15,500 --> 00:11:19,350
And these are just the terms in which AWS thinks.

227
00:11:19,350 --> 00:11:22,190
You will, of course, see all these things in action

228
00:11:22,190 --> 00:11:24,993
and working together over the next lectures.

229
00:11:25,840 --> 00:11:27,640
So let's click Next then.

230
00:11:27,640 --> 00:11:31,580
And the last thing we need to configure is our cluster.

231
00:11:31,580 --> 00:11:34,640
You could say that's the overall network

232
00:11:34,640 --> 00:11:36,900
in which our services run.

233
00:11:36,900 --> 00:11:38,570
Here, we have just one service

234
00:11:38,570 --> 00:11:40,590
with one task with one container,

235
00:11:40,590 --> 00:11:42,530
but if you had a multi-container app,

236
00:11:42,530 --> 00:11:46,140
you could group multiple containers in one cluster

237
00:11:46,140 --> 00:11:48,880
so that they all belong together logically,

238
00:11:48,880 --> 00:11:51,790
and they all can talk to each other.

239
00:11:51,790 --> 00:11:54,960
Now here, we automatically get this cluster network

240
00:11:54,960 --> 00:11:57,570
created for us, and therefore the only thing

241
00:11:57,570 --> 00:12:00,580
we need to do now is click Next.

242
00:12:00,580 --> 00:12:02,470
This gives us this Review page,

243
00:12:02,470 --> 00:12:04,370
where we can have a look whether everything

244
00:12:04,370 --> 00:12:05,900
is configured the way we want,

245
00:12:05,900 --> 00:12:08,530
and then I'm gonna click on Create.

246
00:12:08,530 --> 00:12:12,190
AWS will set up all the things it needs

247
00:12:12,190 --> 00:12:15,360
to launch that container when needed

248
00:12:15,360 --> 00:12:17,750
in the way you told it to do so.

249
00:12:17,750 --> 00:12:20,270
Now, this can take a couple of minutes here,

250
00:12:20,270 --> 00:12:24,003
and I'll be back once setting up all of that finished.

251
00:12:26,380 --> 00:12:30,140
So now, this finished, everything was set up,

252
00:12:30,140 --> 00:12:32,663
and we can now click on view service.

253
00:12:33,690 --> 00:12:36,310
Now, this page might look overwhelming.

254
00:12:36,310 --> 00:12:40,210
Here, you can see all the details of the environment

255
00:12:40,210 --> 00:12:42,867
and the configuration that was created by AWS.

256
00:12:43,970 --> 00:12:46,100
Now, for us, it's probably most interesting

257
00:12:46,100 --> 00:12:48,760
to see our running application.

258
00:12:48,760 --> 00:12:51,420
And you can see this by clicking on Tasks,

259
00:12:51,420 --> 00:12:54,680
and then click on that task which was created here.

260
00:12:54,680 --> 00:12:57,060
Important, on that task ID,

261
00:12:57,060 --> 00:13:01,130
not on the task definition, but on the task ID.

262
00:13:01,130 --> 00:13:04,140
And here, you'll find a public IP.

263
00:13:04,140 --> 00:13:07,920
Now, you could map your own domain to that public IP.

264
00:13:07,920 --> 00:13:11,340
I'll just paste this public IP into the browser,

265
00:13:11,340 --> 00:13:15,020
and I see my running application.

266
00:13:15,020 --> 00:13:19,900
And that's how we can now run it with help of AWS ECS.

267
00:13:19,900 --> 00:13:22,410
Now, this might still look overwhelming,

268
00:13:22,410 --> 00:13:23,930
but the huge advantage here

269
00:13:23,930 --> 00:13:28,500
is that we didn't start any custom servers or machines.

270
00:13:28,500 --> 00:13:31,870
We did not install anything, and we're not responsible

271
00:13:31,870 --> 00:13:34,320
for keeping anything up to date.

272
00:13:34,320 --> 00:13:38,700
We just configured how AWS should execute our containers,

273
00:13:38,700 --> 00:13:40,230
and that is it.

274
00:13:40,230 --> 00:13:42,430
There's nothing else to it.

275
00:13:42,430 --> 00:13:43,910
So now, let me also show you

276
00:13:43,910 --> 00:13:47,690
how we could update our container or our image

277
00:13:47,690 --> 00:13:49,100
on which this container is based

278
00:13:49,100 --> 00:13:52,880
and reflect those changes on this running cluster

279
00:13:52,880 --> 00:13:55,390
before we then thereafter also have a look

280
00:13:55,390 --> 00:13:57,593
at multi-container applications.

