-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
588 lines (563 loc) · 15.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>
Docker and Containers
</title>
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" href="dist/reset.css" />
<link rel="stylesheet" href="dist/reveal.css" />
<link rel="stylesheet" href="dist/theme/solarized.css" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css" />
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>
Docker and Containers
</h2>
<div>
<img src="assets/main-logo.png" width="200" />
</div>
<small>
Cloud Computing Workshop
</small>
<br />
<small>
Dr. Javadi
</small>
<br />
<small>
Presented by Javad Rajabi and Amirhossein Najafizadeh
</small>
<br />
<small>
Spring 2023
</small>
</section>
<section>
<h3>
Workshop Content
</h3>
<ul>
<li>
Containers
<ul>
<li>
OS level virtualization
</li>
<li>
History
</li>
<li>
Isolation
</li>
<li>
Architecture
</li>
<li>
Cgroups
</li>
<li>
Namespaces
</li>
<li>
RunC
</li>
</ul>
</li>
</ul>
<ul>
<li>
Docker
<ul>
<li>
Image
</li>
<li>
Container
</li>
<li>
Network
</li>
<li>
Volume
</li>
<li>
Dockerfile
</li>
<li>
Dockerhub
</li>
<li>
Swarm
</li>
</ul>
</li>
</ul>
</section>
<section>
<section>
<h3>
OS level virtualization
</h3>
<p>
OS-level virtualization is a technology that partitions
the operating system to create multiple isolated containers.
An OS-level container is a virtual execution environment that can be forked instantly
from the base operating environment.
</p>
<table class="c-table">
<tr>
<th></th>
<th>Hypervisor?</th>
<th>How many OS?</th>
</tr>
<tr>
<th>Hardware Level</th>
<th>Yes</th>
<th>Multi OS</th>
</tr>
<tr>
<th>OS Level</th>
<th>No</th>
<th>Single OS</th>
</tr>
</table>
</section>
<section>
<h3>
OS System level virtualization (cont.)
</h3>
<img src="assets/os-virtualization.png" width="600" />
</section>
</section>
<section>
<h3>
History
</h3>
<p>
The concept of containers was started way back in 1979 with UNIX chroot.
It's an UNIX operating-system system call for changing the root directory of a
process and it's children to a new location in the filesystem which is
only visible to a given process.<br /><br />
The 2000s were alight with container technology development and refinement.
Google introduced Borg, the organization's container cluster management system, in 2003.
It relied on the isolation mechanisms that Linux already had in place.<br /><br />
Until 2004 that linux added the Cgropus and Namespaces which started a big
evolution in containers industery.
</p>
</section>
<section>
<section>
<h3>
Containers: Isolation
</h3>
<p>
Container isolation involves isolating a containerized application's
runtime environment from the host operating system and other
processes running on the host.
</p>
</section>
<section>
<h3>
Isolation (cont.)
</h3>
<img src="assets/isolation.png" width="650" />
</section>
</section>
<section>
<h3>
Containers: Architecture
</h3>
<p>
A <span class="green-highlight">containerized</span> architecture makes it possible to package
software and its dependencies in an isolated unit, called a container,
which can run consistently in any environment.
</p>
</section>
<section>
<h3>
Architecture (cont.)
</h3>
<img src="assets/architecture.png" width="650" />
</section>
<section>
<h3>
Cgroup
</h3>
<p>
Cgroups (abbreviated from <span class="red-highlight">control groups</span>)
is a Linux kernel feature that limits,
accounts for, and isolates the resource usage (CPU, memory, disk I/O,
network, etc.) of a collection of processes.
Engineers at Google started the work on this feature in 2006
under the name <span class="blue-highlight">process containers</span>.
</p>
</section>
<section>
<h3>
Namespace
</h3>
<p>
Namespaces are a feature of the Linux kernel that partitions kernel
resources such that one set of processes <span class="red-highlight">
sees one set of resources while another</span>
set of processes sees a different set of resources.<br />
Namespaces provide isolation of system resources, and cgroups allow for
<span class="blue-highlight">fine‑grained control and enforcement of limits for those resources</span>.
Containers are not the only way that you can use namespaces and cgroups.
</p>
</section>
<section>
<h3>
RunC
</h3>
<p>
RunC is a CLI tool for spawning and running containers on Linux according to the
<span class="green-highlight">OCI specification</span>.
RunC is a universal container runtime created by <span class="blue-highlight">Docker
</span>. View it on
<a href="https://github.com/opencontainers/runc">
Github
</a>.
</p>
<pre><code>
# creating a new containers
runc create mycontainerid
# view the container is created and in the "created" state
runc list
# start the process inside the container
runc start mycontainerid
# now delete the container
runc delete mycontainerid
</code></pre>
</section>
<section>
<h3>
Docker
</h3>
<p>
Docker is a software platform that allows you to build, test, and deploy applications quickly.
Docker packages software into standardized units called containers that have everything
the software needs to run including libraries, system tools, code, and runtime. Docker created
<span class="blue-highlight">RunC</span> in order to manage containers on a system.
</p>
</section>
<section>
<h3>
Docker (cont.)
</h3>
<img style="background-color: #fff; padding: 10px;" src="assets/docker.svg" width="650" />
</section>
<section>
<h3>
Docker: Image
</h3>
<p>
A Docker image is a read-only template that contains a set of
instructions for creating a container that can run on the Docker platform.
An image is a <span class="green-highlight">file that represents a packaged application with all the
dependencies needed to run correctly</span>.
In other words, we could say that a Docker image is like a Java class.
Images are built as a series of layers. Layers are assembled on top of one another.
<span class="red-highlight">Layers can also be cached</span>.
</p>
<img src="assets/image.png" width="450" />
</section>
<section>
<h3>
Docker: Image (cont.)
</h3>
<p>
Image commands:
</p>
<pre><code>
# pull docker image
$ docker pull nginx:latest
# get a list of docker images
$ docker image ls
# build your docker image
$ docker build . -t amirhossein21/nginx:v0.1
# remove an image
$ docker image remove amirhossein21/nginx:v0.1
</code></pre>
</section>
<section>
<h3>
Docker: Container
</h3>
<p>
A Docker container image is a lightweight, standalone, executable package of software that
includes everything needed to run an application: code, runtime, system tools, system libraries
and settings.
</p>
<img src="assets/containers.jpeg" width="550" />
</section>
<section>
<h3>
Docker: Container (cont.)
</h3>
<p>
The key difference between a Docker image and a container is that a Docker
image is a read-only immutable template that defines how a container will be realized.<br />
A Docker container is a runtime instance of a Docker image that gets created
when the <span class="blue-highlight">$ docker run command</span> is implemented.
</p>
</section>
<section>
<h3>
Docker: Container (cont.)
</h3>
<p>
Container commands:
</p>
<pre><code>
# run a container
$ docker run -d -p 80:80 nginx:latest
# view containers
$ docker ps
# remove container
$ docker stop b5ee41eeb951
# get terminal inside a container
$ docker exec -it 39203d3aea67 bash
</code></pre>
</section>
<section>
<h3>
Docker: Network
</h3>
<p>
Docker networking allows you to attach a container to as many networks as you like.
You can also attach an already running container.<br />
There are three common Docker network types –
bridge networks, used within a single host, overlay networks,
for multi-host communication, and macvlan networks which are used to connect Docker
containers directly to host network interfaces.
</p>
</section>
<section>
<h3>
Network (cont.)
</h3>
<img src="assets/network.png" width="600" />
</section>
<section>
<h3>
Network (cont.)
</h3>
<p>
Network commands:
</p>
<pre><code>
# create network
$ docker network create node-app-network
# get a list of networks
$ docker network ls
# run a container on network
$ docker run --network=node-app-network -d -p 80:80 nginx:latest
# remove network
$ docker network remove node-app-network
</code></pre>
</section>
<section>
<h3>
Docker: Volume
</h3>
<p>
A Docker volume is an independent file system entirely managed by Docker and exists as a
normal file or directory on the host, where data is persisted.
Volumes are the preferred way to persist data in Docker containers and services.
Some use cases for volumes include: Sharing data among multiple running containers.
If you don't explicitly create it, a volume is created the first time it is mounted into a container.
</p>
</section>
<section>
<h3>
Volume (cont.)
</h3>
<img src="assets/volume.png" width="600" />
</section>
<section>
<h3>
Volume (cont.)
</h3>
<p>
Volume commands:
</p>
<pre><code>
# create volume
$ docker volume create redisvolume
# get a list of networks
$ docker volume ls
# run a container on network
$ docker run -v redisvolume:/data redis:latest
# remove network
$ docker volume remove redisvolume
</code></pre>
</section>
<section>
<h3>
Dockerfile
</h3>
<p>
A Dockerfile is a text document that contains all the commands a user could call on
the command line to assemble an image.
</p>
<pre><code>
# select a base image
FROM nginx
# run a command
RUN apt-get upgrade
# execute commands
COPY html /var/www/html
# run a cmd command for container
CMD bash
</code></pre>
</section>
<section>
<h3>
Dockerhub
</h3>
<p>
Docker Hub is the world’s largest repository of container images with an array of
content sources including container community developers, open source projects.
</p>
<pre><code>
# login
$ docker login
# push images
$ docker push amirhossein21/nginx:v0.1
</code></pre>
</section>
<section>
<h3>
Docker Compose
</h3>
<p>
Docker Compose is a tool that was developed to help define and share multi-container
applications. With Compose, we can create a YAML file to define the
services and with a single command, can spin everything up or tear it all down.
Network, volume and etc.
</p>
</section>
<section>
<h3>
Compose (cont.)
</h3>
<p>
Make a
<span style="background-color: #fff; color: rgb(255, 75, 75); padding: 0 5px;">docker-compose.yml</span>
file.
</p>
<pre><code>
version: "3.9" # optional since v1.27.0
services:
web:
build: .
ports:
- "8000:5000"
depends_on:
- redis
redis:
image: redis
volumes:
- logvolume01:/data
volumes:
logvolume01: {}
</code></pre>
</section>
<section>
<h3>
Compose (cont.)
</h3>
<p>
Docker Compose commands:
</p>
<pre><code>
# start containers
$ docker compose up -d
# stop containers
$ docker compose down
</code></pre>
</section>
<section>
<h3>
Docker Swarm
</h3>
<p>
A Docker Swarm is a container orchestration tool running the Docker application.
It has been configured to join together in a cluster.<br />
One of the key benefits associated with the operation of a docker swarm is the
high level of availability offered for applications. Docker Swarm
lets you connect containers to multiple hosts similar to Kubernetes.
Docker Swarm has two types of services: replicated and global.
</p>
</section>
<section>
<h3>
Swarm (cont.)
</h3>
<img src="assets/swarm.png" width="650" />
</section>
<section>
<h2>
References
</h2>
<ul>
<li>
<a href="https://snyk.io/blog/best-practices-for-container-isolation/#:~:text=What%20is%20container%20isolation%2C%20and,processes%20running%20on%20the%20host.">
https://snyk.io/blog
</a>
</li>
<li>
<a href="https://www.aquasec.com/cloud-native-academy/container-security/containerized-architecture/#:~:text=What%20is%20a%20Containerized%20Architecture,run%20consistently%20in%20any%20environment.">
https://aquasec.com/cloud-native-academy
</a>
</li>
<li>
<a href="https://en.wikipedia.org/wiki/Cgroups#:~:text=cgroups%20(abbreviated%20from%20control%20groups,of%20a%20collection%20of%20processes.">
https://en.wikipedia.org/wiki/cgroups
</a>
</li>
<li>
<a href="https://aws.amazon.com/docker/#:~:text=Docker%20is%20a%20software%20platform,tools%2C%20code%2C%20and%20runtime.">
https://aws.amazon.com/docker
</a>
</li>
<li>
<a href="https://www.docker.com/products/docker-hub/">
https://docker.com
</a>
</li>
<li>
<a href="https://www.sumologic.com/glossary/docker-swarm/#:~:text=with%20Sumo%20Logic-,What%20is%20a%20Docker%20Swarm%3F,join%20together%20in%20a%20cluster.">
https://sumologic.com/docker-swarm
</a>
</li>
</ul>
</section>
</div>
<div id="slide-counter" style="position: fixed; left: 0; bottom: 0;"></div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
</script>
</body>
</html>