Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit c02cadd

Browse files
committed
updated docker slides
1 parent 2d50c9b commit c02cadd

9 files changed

+1578
-0
lines changed

intro-to-docker-pt2.html

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<!--
6+
The contents of this file are based on index.html from the reveal.js project.
7+
Some details such as dependancies may not be needed or may change in the future.
8+
Once it has been written, this template and any lectures based off of it should
9+
be accompanied by a shell script to set up and/or run the presentation with minimal
10+
user interference.
11+
-->
12+
<meta charset="utf-8">
13+
14+
<title>Zip Code Lecture: Intro to Docker</title>
15+
16+
<meta name="description" content="A reveal.js-based Zip Code Wilmington Lesson: Intro to Docker">
17+
<!-- TODO: Put your name here: -->
18+
<meta name="author" content="Roberto DeDeus">
19+
20+
<meta name="apple-mobile-web-app-capable" content="yes">
21+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
22+
23+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
24+
25+
<link rel="stylesheet" href="css/reveal.css">
26+
<link rel="stylesheet" href="css/theme/black.css" id="theme">
27+
28+
<!-- Code syntax highlighting -->
29+
<link rel="stylesheet" href="lib/css/zenburn.css">
30+
31+
<!-- Printing and PDF exports -->
32+
<script>
33+
var link = document.createElement( 'link' );
34+
link.rel = 'stylesheet';
35+
link.type = 'text/css';
36+
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
37+
document.getElementsByTagName( 'head' )[0].appendChild( link );
38+
</script>
39+
<!-- fix the inline code block style -->
40+
<style>
41+
.reveal code {
42+
background: #3f3f3f;
43+
padding: 0px 4px;
44+
}
45+
</style>
46+
47+
<!--[if lt IE 9]>
48+
<script src="lib/js/html5shiv.js"></script>
49+
<![endif]-->
50+
</head>
51+
52+
<body>
53+
54+
<div class="reveal">
55+
56+
<!-- Any section element inside of this container is displayed as a slide -->
57+
<div class="slides">
58+
59+
<section>
60+
<!-- This logo is used in every copy of this file. Drop a new file
61+
into img/Logo.jpg to change it across all slide decks -->
62+
<img src="img/Logo.jpg" >
63+
</section>
64+
65+
<!--
66+
So that new slides are easily recognizable while editing markdown
67+
the separators have been changed to be one or two <hr>s (- by itself on a line).
68+
1 hr = new slide below
69+
2 hr = new slide to the right
70+
-->
71+
<section data-markdown="md/intro-to-docker-pt2.md"
72+
data-separator="^-\n-\n"
73+
data-separator-vertical="^-\n"
74+
data-separator-notes="^Note:"
75+
data-charset="utf-8">
76+
</section>
77+
<section>
78+
<!-- cute animal -->
79+
<img src="img/bunnies/cute-bunny-photos20.jpg">
80+
</section>
81+
</div>
82+
83+
</div>
84+
85+
<script src="lib/js/head.min.js"></script>
86+
<script src="js/reveal.js"></script>
87+
88+
<script>
89+
90+
// Full list of configuration options available at:
91+
// https://github.com/hakimel/reveal.js#configuration
92+
Reveal.initialize({
93+
controls: true,
94+
progress: true,
95+
history: true,
96+
center: true,
97+
98+
transition: 'slide', // none/fade/slide/convex/concave/zoom
99+
100+
// Optional reveal.js plugins
101+
dependencies: [
102+
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
103+
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
104+
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
105+
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
106+
{ src: 'plugin/zoom-js/zoom.js', async: true },
107+
{ src: 'plugin/notes/notes.js', async: true }
108+
]
109+
});
110+
111+
</script>
112+
113+
</body>
114+
</html>

intro-to-docker.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
data-separator-notes="^Note:"
7575
data-charset="utf-8">
7676
</section>
77+
<section>
78+
<!-- cute animal -->
79+
<img src="img/bunnies/cute-bunny-photos20.jpg">
80+
</section>
7781

7882
</div>
7983

md/intro-to-docker-pt1.2.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# Intro to Docker
2+
### Unit: 1 Containers
3+
CLI Monitoring
4+
5+
6+
-
7+
8+
### What’s going on in Containers:
9+
● docker container top - process list in one container
10+
● docker container inspect - details of one container config
11+
● docker container stats - performance stats for all containers
12+
13+
14+
-
15+
16+
### Let’s start a nginx container
17+
● docker container run -d --name nginx nginx
18+
● docker container top nginx
19+
20+
21+
-
22+
23+
### Let’s start a mysql container
24+
● docker container run -d --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
25+
● docker container top mysql
26+
27+
28+
-
29+
30+
### Docker container inspect
31+
● docker container inspect mysql
32+
● This will return a JSON array of all the data involved in starting up the
33+
container
34+
35+
36+
-
37+
38+
### Docker container stats
39+
● docker container stats
40+
● This will give you a running play on the processes running in containers on
41+
your machine
42+
● This is not what you would use in production
43+
● It’s great for when you are working on your local machine
44+
45+
46+
-
47+
48+
### Getting a Shell inside Containers
49+
● docker container run -it
50+
○ starts new containers interactively
51+
● docker container exec -it
52+
○ run additional command in existing container
53+
● Different Linux distros in containers
54+
55+
56+
-
57+
58+
### Container flags `-i` , `-t` or `-it`
59+
● -t pseudo-tty
60+
○ Simulates a real terminal, like what SSH does
61+
● -i, --interactive
62+
○ Keep STDIN open even if not attached
63+
○ This allows us to keep the session open even when there are no commands
64+
65+
66+
-
67+
68+
### Container additional commands
69+
● usage : docker container run [OPTIONS] IMAGE [COMMAND] [ARGS...]
70+
● docker container run -it --name proxy nginx bash
71+
○ Here by placing bash after the image name ‘nginx’ we are overriding the default action of
72+
this container
73+
○ This will log you in as the root user of the container
74+
○ Try using ls
75+
○ Using the exit command to leave the container and end.
76+
○ Containers only run as log as the command on startup
77+
78+
79+
-
80+
81+
### Let’s pull down a full distribution
82+
● docker container run -it --name ubuntu ubuntu
83+
○ Once logged in run apt-get update
84+
○ This is a stripped down version of Ubuntu , and would not contain all the things that comes
85+
with a full distribution by default.
86+
○ You can even install things normally apt-get install -y curl
87+
○ Once you exit the container again... it will stop the container
88+
○ If we restarted the container CURL would be installed
89+
90+
91+
-
92+
93+
### Docker container start
94+
● docker container start --help
95+
● -a, --attach :: Attach STDOUT/STDERR and forward signals
96+
● docker container start -ai ubuntu
97+
98+
Docker container exec
99+
● Let's say we want to look inside of an container already running a process
100+
● docker container exec -it mysql bash
101+
○ Will place you in a container inside of sql
102+
○ In this shell we can jump directly into the mysql command line
103+
○ Try ps aux
104+
○ When you finally exit the process will continue
105+
○ run docker ps
106+
107+
108+
-
109+
110+
### Linux Alpine
111+
● A small security focused distribution of linux
112+
● Lets pull down a copy of alpine and take a look
113+
○ docker pull alpine
114+
○ docker image ls
115+
● Let’s try :
116+
○ docker container run -it alpine bash
117+
○ The above will not work because bash is not part of the distribution
118+
● Lets try:
119+
○ docker container run -alpine sh
120+
○ The above will work because sh is include in this image, although it has less features
121+
available than bash.
122+
123+
124+
-
125+
126+
# Unit: 1 Containers
127+
### Networking Concepts
128+
129+
130+
-
131+
132+
### Docker Networks: Concepts
133+
● Review of docker container run -p
134+
● For local dev/testing, networks usually “just work”
135+
○ Dockers motto Batteries are included but removable
136+
● Quick porr check with docker container port <container>
137+
● Learn concepts of Docker Networking
138+
139+
140+
-
141+
142+
### Docker Network Defaults
143+
● Each container connected to a private virtual network “bridge” ○ This is the default docker system network
144+
● Each virtual network routes through NAT firewall on host IP
145+
○ The docker daemon configures the host ip address on its default interface so that
146+
containers can get out to the internet
147+
● All containers on a virtual network can talk to each other with -p
148+
● Best practice is to create a new virtual network for each app
149+
○ Network “zcw_web_app” for mysql and php/apache containers
150+
○ Network “zcw_api” for mongo and nodejs containers
151+
152+
153+
-
154+
155+
### Docker Networks Cont.
156+
● “Batteries Included, But Removable”
157+
○ Default work well in many cases, but easy to swap out parts to customize it
158+
● Things you can change
159+
○ Make new virtual networks
160+
○ Attach containers to more than one virtual network (or none)
161+
○ Skip virtual networks and use host IP (--net=host)
162+
■ You lose contanerization benefits but it’s unavoidable ○ Use different Docker network drivers to gain new abilities
163+
164+
165+
-
166+
167+
### `-p (--publish)`
168+
● Publishing ports is always in HOST:CONTAINER format
169+
● RUN: docker container run -p 80:80 --name webhost -d nginx
170+
● RUN: docker container port webhost
171+
○ 80/tcp -> 0.0.0.0:80
172+
173+
174+
-
175+
176+
### Inspect `--format`
177+
● docker container inspect --format '{{ .NetworkSettings.IPAddress }}' webhost ○ Will return the ip address of the container ‘172.17.0.3’
178+
● Run: ifconfig en0
179+
○ Will return the ip address of local machine ‘10.0.0.92’
180+
○ Notice that the two machines are not on the same network
181+
○ There is an edge firewall that blocks calls in and out
182+
○ Docker has a default bridge that maps to our local ethernet interface
183+
○ Using the -p on docker will allow external traffic into the docker virtual network
184+
○ Containers on the same network have access to each other, unless you use -p there will be
185+
no incoming calls.
186+
187+
188+
-
189+
190+
### Docker Networks: Concepts recap
191+
● Review of docker container run -p
192+
● For local/dev testing, networks usually “just work”
193+
● Quick port check with docker container port <container>
194+
● Learn concepts of Docker networking
195+
196+
197+
-
198+
199+
# Unit: 1 Containers
200+
### CLI Management
201+
202+
203+
-
204+
205+
### Docker Networks : CLI Management
206+
● Show networks docker network ls
207+
● Inspect a network docker network inspect
208+
● Create a network docker network create --driver
209+
● Attach a network to a container docker network connect
210+
● Detach a network from container docker network disconnect
211+
212+
213+
-
214+
215+
### Docker Networks
216+
● Run : docker network ls
217+
● Run : docker network inspect bridge
218+
○ Will list the containers that are attached to this network
219+
● Three default networks
220+
○ Host network - a special network that skips virtual networks but sacrifices security of a
221+
container
222+
○ Bridge network - default network for docker host
223+
○ None network - it has not attachment
224+
225+
226+
-
227+
228+
### Docker Networks
229+
● Run : docker network create zcw_app_network
230+
● Run : docker network ls
231+
○ We can now see our new network with a driver of bridge ■ Bridge is the default network driver
232+
● Run : docker network create --help
233+
● Run : docker container run -d --name new_nginx --network zcw_app_network nginx
234+
● Run : docker network inspect zcw_app_network
235+
236+
237+
-
238+
239+
### Docker Networks :
240+
● Docker network connect
241+
○ Dynamically creates a NIC (networking interface card) in a container on an existing virtual
242+
network
243+
● Run : docker network ls
244+
● Run : docker network inspect bridge
245+
246+
247+
-
248+
249+
### Lab : CLI Testing
250+
● Use different Linux distro containers to check curl cli tool versions
251+
● Use two different terminal windows to start bash in both centos:7 and
252+
ubuntu:14.04, using -it
253+
● Use the docker container --rm options so you can save cleanup
254+
● Ensure curl is installed and on latest version for that distro
255+
○ ubuntu : apt-get update && apt-get install curl
256+
○ Centos : yum update curl
257+
● check curl --version
258+

0 commit comments

Comments
 (0)