diff options
-rwxr-xr-x | examples/example1.sh | 22 | ||||
-rwxr-xr-x | examples/example2.sh | 18 | ||||
-rw-r--r-- | examples/example3/Dockerfile | 5 | ||||
-rwxr-xr-x | examples/example3/example3.sh | 22 | ||||
-rw-r--r-- | slides.md | 145 |
5 files changed, 212 insertions, 0 deletions
diff --git a/examples/example1.sh b/examples/example1.sh new file mode 100755 index 0000000..d441d9a --- /dev/null +++ b/examples/example1.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Cody Hiar +# Date: 2019-01-15 +# +# Description: Show how quickly a docker container +# can boot up, run a command, and then boot down. +# +# Set options: +# e: Stop script if command fails +# u: Stop script if unset variable is referenced +# x: Debug, print commands as they are executed +# o pipefail: If any command in a pipeline fails it all fails +# +set -exuo pipefail + +# Run a container +time docker run --rm -it ubuntu:18.04 /bin/bash -c 'echo Hello World' + +# Show size of docker container +docker images | grep '18.04' diff --git a/examples/example2.sh b/examples/example2.sh new file mode 100755 index 0000000..ab4faff --- /dev/null +++ b/examples/example2.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Cody Hiar +# Date: 2019-01-15 +# +# Description: Dockerize the `date` command +# +# Set options: +# e: Stop script if command fails +# u: Stop script if unset variable is referenced +# x: Debug, print commands as they are executed +# o pipefail: If any command in a pipeline fails it all fails +# +set -exuo pipefail + +# Run a container +docker run --rm -it ubuntu:18.04 /bin/bash -c date "$@" diff --git a/examples/example3/Dockerfile b/examples/example3/Dockerfile new file mode 100644 index 0000000..9fb6973 --- /dev/null +++ b/examples/example3/Dockerfile @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y vim + +WORKDIR /usr/src/app diff --git a/examples/example3/example3.sh b/examples/example3/example3.sh new file mode 100755 index 0000000..b1676a4 --- /dev/null +++ b/examples/example3/example3.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Cody Hiar +# Date: 2019-01-15 +# +# Description: Show how to build image, then run +# it. +# +# Set options: +# e: Stop script if command fails +# u: Stop script if unset variable is referenced +# x: Debug, print commands as they are executed +# o pipefail: If any command in a pipeline fails it all fails +# +set -exuo pipefail + +# Build the image +docker build -t vim_image . + +# Run the image +docker run --rm -it -v "$(pwd)":/usr/src/app vim_image /bin/bash -c vim diff --git a/slides.md b/slides.md new file mode 100644 index 0000000..89ecc3f --- /dev/null +++ b/slides.md @@ -0,0 +1,145 @@ +%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 for possibilites + +-> 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.sh demo + +------------------------------------------------- + +-> 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 + +There will be no demo of a VM time equivalent + +------------------------------------------------- + +If the time difference between running a program +on the machine and running a program in a +container is negligible, then why don't we start +running all commands inside of containers? + +------------------------------------------------- + +Answer: We don't understand Docker yet. But after +this we will! + +------------------------------------------------- + +-> Let's dockerize a command <- +=============================== + +example2.sh demo + +------------------------------------------------- + +As you can see the run time of the program inside +the container is blazingly fast. We can extend +this concept of dockerizing command by building +our own docker images that install all the +dependancies necessary. + +------------------------------------------------- + +-> Introducting Docker Files <- +=============================== + +Dockerfiles are a set of instructions that build a +docker image which can then be ran locally, shared +with others, and even extended to be included in +other docker files. |