aboutsummaryrefslogtreecommitdiff
path: root/slides.md
blob: 2f15951d4c181f97f6d48c16ddc57a3b4699ef13 (plain)
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
%title: Docker for Homo Troglodytes
%author: Cody Hiar
%date: 2019-01-15

-> Docker for Homo Troglodytes <-
=================================

-------------------------------------------------

# About Me

* Graduated Computer Engineering at U of A
* Now working remotely @ Blendable
* Vim/Tmux Diehard, also cli in general
* Interests: Python, Automation, DevOps, Linux

# Where I be

* www.codyhiar.com
* www.github.com/thornycrackers

# Past Presentations (available on GitHub)

* Scraping with scrapy (YEGSEC)
* Python Daemons (Edmonton.py)
* Setting Django up on a VPS (Edmonton.py)

-------------------------------------------------

-> My Goals <-
==============

* Help build a mental model of Docker
* Introduce Docker basics
* Give some working examples
* Show potential of what's possible

-> My Assumptions <-
====================

* You know what the concept of a VM is 
* Little to no experience with Docker
* You know _some_ linux
* Take things with a grain of salt

-------------------------------------------------

-> What is Docker? <-
====================

```
Docker == VM      // True
Docker === VM     // False
```

^

For all intents and purposes, you can use your
mental model of a VM for Docker.  Some people will
argue that there is a difference, usually their
answers are ostentatious.

-------------------------------------------------

Handy Chart of Advantages
=========================

| Feature     | VM | Docker |
| ----------- | -- | ------ |
| Size        | **  |   **    |
| Startup     | **  |   **    |
| Integration | **  |   **    |

Docker vs Vagrant
MBs vs GBs
Seconds vs Minutes


-------------------------------------------------

-> Installation <-
==================

- Mac/Windows https://www.docker.com/get-started
- Linux:
    https://www.digitalocean.com/community/tutorials
    /how-to-install-and-use-docker-on-ubuntu-16-04

(Article includes CentOs 7, Debian 9, Ubuntu 18.04)

-------------------------------------------------

-> Pfffft Let's see it <-
=========================

example1 demo

- Run script 
- Explain commands
- Look at execution time
- Look at image size

-------------------------------------------------

-> What Happened? <-
====================

> "What goes up must come down" -Isaac Newton

1. Docker looked for image (Downloads if needed)
2. Docker spins up a container
3. Container runs `echo Hello World`
4. Docker spins down the container
4. Docker removed the container

There will be no demo of a VM time equivalent

-------------------------------------------------

Q: If the time difference between running a command
on the machine and running a command in a
container is negligible, then why don't we start
running all commands inside of containers?

-------------------------------------------------

A: We don't understand Docker yet. But after
this we will!

-------------------------------------------------

-> Let's dockerize the 'date' command <-
========================================

example2 demo

- show `date` command
- show script with docker command explain '$@' args
- run `date -d yesterday` locally and with script
- move script to somewhere on $PATH to execute

-------------------------------------------------

As you can see the run time of the command inside
the container is blazingly fast. `date` was already built
into the container so look at how to install a package.

-------------------------------------------------

-> Introducting Docker Files <-
===============================

Docker images are synonymous with VM snapshots. They take a
'picture' of the current container. While it is possible to
start a container, install/set it up, and then export the
container as an image, the best way to create images is by
using a Dockerfile. Dockerfiles are step by step set of
instructions on how to create an image that will be able to
run an application. 

-------------------------------------------------

-> Let's dockerize Vim <-
=========================

example3 demo

- Show Dockerfile
- Show script, explain docker build
- Explain layers for caching and build context
- Explain the volumes for mounting files

-------------------------------------------------

-> A Quick Intermission: <-
===========================
-> Compiled vs Intepreted Programming Languages <-
==================================================

Once upon a time, programming langauges were compiled to
binaries and everyone was happy. Then the evil Alan Kay
led the creation of Smalltalk at Xerox PARC which influenced
future programming languages with evil concepts like object
oriented programming and compiling at run time. Now we have
to live with the evil Alan Kay's cruel intentions and will
never know true happiness again.

The End

-------------------------------------------------

-> Using language specific images <-
====================================

Some langauges, such as python, ruby, and javascript,
are compiled at run time when they are run. This means that
you need to have that language's ecosystem installed on your
machine to run a tool programmed in that language. Docker
provides official images for many languages which provide
required low level libraries and usually the languages
package manager so that you can quickly get up and running.
Now we don't have to pick tools based on their languages.

-------------------------------------------------

-> Let's dockerize Babysploit <-
================================

example4 demo

- Babysploit provides own container, we'll try our own
- Show Dockerfile and script

-------------------------------------------------

-> A Beginner's Summary <-
==========================

- We have a loose general idea of what Docker is
- We've seen how fast/small docker images are
- We have a framework for running images similar to binaries
- Dockerfiles provide us with step by step instructions on
    how to build the environment for an application as well
    as define the boundaries of an application
- We can use tools written in languages we don't know
    without having to research how to set the the languages
    environment, and even do development on the tool

-------------------------------------------------

-> What about GUI Apps? <-
==========================

Ok let's kick it up.

So far we've only been working with simple binaries on the
command line but docker is capable of much, much more. How
about GUI aplications? 

* Note: This example is for linux users only
* ref: https://blog.jessfraz.com/post/
*      docker-containers-on-the-desktop/

-------------------------------------------------

-> Let's dockerize Spotify <-
=============================

example5 demo

- Explain how display can be shared with volumes
- Run spotify

-------------------------------------------------

-> Managing Multiple Containers? <-
===================================

Docker compose is a tool for defining multi container
environments that allow us to create a repeatable
infrastructure setup so that we can build complex
environments that have complex requirements.

-------------------------------------------------

-> Setting up a WordPress site <-
=================================

example6 demo

- Show and explain compose.yml file
- Bring up site and show in browser

-------------------------------------------------

-> Automating Docker commands with Makefile <-
==============================================

Typing out the long Docker commands can become very tedious.
My recommended approach to solving this to use a `Makefile`
to automate building and running the containers. Once you
start integrating with CI pipeline you can use the Makefiles
to help you ensure that your project runs correcly
everywhere.

-------------------------------------------------

-> Create a Templated Project with CookieCutter <-
==================================================

example7 demo

- Run the command to generate project
- Explain files

-------------------------------------------------

And now for my final trick...

-------------------------------------------------

-> Docker inside Docker <-
==========================

What about running docker inside of a docker container?
Let's set up a Jenkins server that will mount the hosts
docker binary and socket so that it can build containers
while itself being inside a container

-------------------------------------------------

-> Ow, my head! <-
==================

+----------------------------------+
|   Host        +----------------+ |
|               |                | |
|               |                | |
|  binary <-------->    Jenkins  | |
|               |                | |
|  socket <-------->             | |
|               |                | |
|               +----------------+ |
|                                  |
|   my_image_1                     |
|   my_image_2                     |
|                                  |
|                                  |
+----------------------------------+

-------------------------------------------------

-> Dockerception with Jenkins <-
================================

example8 demo

- Show and explain how sharing works
- Show working example

-------------------------------------------------

-> Hosting <-
=============

- Rancher
- Kubernetes
- Docker Swarm
- Portainer

-------------------------------------------------

-> Additional Resources <-
==========================

(Docker for Beginners)
https://docker-curriculum.com/
(Playground for using Docker)
https://labs.play-with-docker.com/
(Dockerized Desktop Apps)
https://blog.jessfraz.com/post/docker-containers-on-the-desktop/