Skip to content

Commit

Permalink
Initial Docker Chapter (#78)
Browse files Browse the repository at this point in the history
* Rough draft of first chapter

* Consolidate image/container chapter

* Saving work

* Adding additional details to setup section

* Saving work

* saving work

* Mark other containers chapters as draft

* Update the dependencies

* Marking images/containers container as draft... for now
  • Loading branch information
MichaelStott authored Dec 15, 2023
1 parent 8d447d3 commit 5fe45a0
Show file tree
Hide file tree
Showing 32 changed files with 521 additions and 94 deletions.
14 changes: 14 additions & 0 deletions code/containers/docker/images/parent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use Ubuntu as base image for container
FROM ubuntu:23.04

# Install latest packages
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8


# Copy local text file into container
COPY message.txt message.txt

# Print message from file
ENTRYPOINT [ "cat", "message.txt" ]
7 changes: 7 additions & 0 deletions code/containers/docker/images/parent/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


build:
docker build . -t techsqauwks/ubuntu

run:
docker run -t techsqauwks/ubuntu
1 change: 1 addition & 0 deletions code/containers/docker/images/parent/message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from the ubuntu image container!
8 changes: 8 additions & 0 deletions code/containers/docker/images/scratch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# A 'scratch' image is an empty base image.
FROM scratch

# Copy binary executable
COPY hello hello

# Run executable
ENTRYPOINT [ "./hello" ]
6 changes: 6 additions & 0 deletions code/containers/docker/images/scratch/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

build:
docker build . -t techsqauwks/scatch

run:
docker run -t techsqauwks/scatch
19 changes: 19 additions & 0 deletions code/containers/docker/images/scratch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This example demonstrates how to create a "hello world" images using the base image.

To compile the binary to copy into the image.

```sh
GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o hello
```

The example can be build via:

```sh
$ docker build . -t techsqauwks/scatch
```

And run via:

```sh
$ docker run -t techsqauwks/scatch
```
3 changes: 3 additions & 0 deletions code/containers/docker/images/scratch/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module techsquawks/scratch-container

go 1.21.2
Binary file added code/containers/docker/images/scratch/hello
Binary file not shown.
7 changes: 7 additions & 0 deletions code/containers/docker/images/scratch/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello world!")
}
3 changes: 3 additions & 0 deletions code/containers/docker/overview/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM alpine:3.14

ENTRYPOINT [ "echo", "hello world!" ]
6 changes: 6 additions & 0 deletions code/containers/docker/overview/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

build:
@docker build . -t techsqauwks/hello-world

run:
@docker run -t techsqauwks/hello-world
17 changes: 17 additions & 0 deletions code/containers/docker/overview/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Build

```
$ docker build . --tag techsquawks:hello-world
```

## List image

```
$ docker images
```

## Execute

```
$ docker run -t techsquawks:hello-world
```
86 changes: 58 additions & 28 deletions diagrams/docker_architecture.drawio
Original file line number Diff line number Diff line change
@@ -1,47 +1,77 @@
<mxfile host="Electron" modified="2023-09-15T19:21:18.784Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.2.8 Chrome/112.0.5615.165 Electron/24.2.0 Safari/537.36" etag="3ASM-S6MnEe8s6ft6hfk" version="21.2.8" type="device">
<mxfile host="Electron" modified="2023-10-22T20:02:01.837Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.2.8 Chrome/112.0.5615.165 Electron/24.2.0 Safari/537.36" etag="4Ab-EwdY1NtC15F3e5gx" version="21.2.8" type="device">
<diagram name="Page-1" id="W4vNGyYaI7FxQCOn36wm">
<mxGraphModel dx="1038" dy="608" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<mxGraphModel dx="956" dy="621" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-1" value="Docker Client (CLI)" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="130" y="170" width="120" height="260" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-1" value="Docker Client (CLI)" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="120" y="170" width="120" height="260" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-2" value="Docker Host" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="270" y="170" width="290" height="260" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-2" value="Docker Host" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="260" y="170" width="290" height="260" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-3" value="Dockekr Registry" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="580" y="170" width="120" height="260" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-3" value="Docker Hub" style="rounded=1;whiteSpace=wrap;html=1;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="650" y="170" width="120" height="260" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-4" value="Build" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="145" y="190" width="90" height="30" as="geometry" />
<mxCell id="GARBAzdv9NtNetveAKvq-11" style="edgeStyle=orthogonalEdgeStyle;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=-0.02;entryY=0.118;entryDx=0;entryDy=0;entryPerimeter=0;curved=1;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" edge="1" parent="1" source="eiCj1fGub0zI8uFPpaJ1-4" target="eiCj1fGub0zI8uFPpaJ1-14">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-6" value="Run" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="145" y="230" width="90" height="30" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-4" value="Build" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="135" y="200" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-7" value="Pull" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="145" y="270" width="90" height="30" as="geometry" />
<mxCell id="GARBAzdv9NtNetveAKvq-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=-0.013;entryY=0.625;entryDx=0;entryDy=0;entryPerimeter=0;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" edge="1" parent="1" source="eiCj1fGub0zI8uFPpaJ1-6" target="eiCj1fGub0zI8uFPpaJ1-15">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-8" value="Push" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="145" y="310" width="90" height="30" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-6" value="Run" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="135" y="240" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-9" value="etc," style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;dashed=1;" vertex="1" parent="1">
<mxGeometry x="145" y="350" width="90" height="30" as="geometry" />
<mxCell id="GARBAzdv9NtNetveAKvq-17" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.75;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" edge="1" parent="1" source="eiCj1fGub0zI8uFPpaJ1-7" target="eiCj1fGub0zI8uFPpaJ1-14">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="710" y="300" />
<mxPoint x="710" y="319" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-12" value="Developer" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;fillColor=#232F3D;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;pointerEvents=1;shape=mxgraph.aws4.user;" vertex="1" parent="1">
<mxGeometry x="30" y="275" width="35" height="35" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-7" value="Pull" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="135" y="285" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-13" value="Daemon" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="280" y="195" width="80" height="210" as="geometry" />
<mxCell id="GARBAzdv9NtNetveAKvq-18" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.75;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" edge="1" parent="1" source="eiCj1fGub0zI8uFPpaJ1-8" target="eiCj1fGub0zI8uFPpaJ1-17">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="265" y="347" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-14" value="Images" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="370" y="195" width="80" height="165" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-8" value="Push" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="135" y="330" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-15" value="Containers" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="460" y="195" width="90" height="85" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-9" value="etc," style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;dashed=1;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="135" y="370" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-17" value="Images" style="rounded=1;whiteSpace=wrap;html=1;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="600" y="187.5" width="80" height="82.5" as="geometry" />
<mxCell id="eiCj1fGub0zI8uFPpaJ1-13" value="Daemon" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#888888;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="270" y="195" width="80" height="210" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-14" value="Images" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#888888;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="360" y="195" width="80" height="165" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-15" value="Containers" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#888888;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="450" y="195" width="90" height="95" as="geometry" />
</mxCell>
<mxCell id="eiCj1fGub0zI8uFPpaJ1-17" value="Images" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#888888;fontFamily=Verdana;sketch=1;curveFitting=1;jiggle=2;labelPosition=center;verticalLabelPosition=top;align=center;verticalAlign=bottom;strokeColor=#888888;fontColor=#888888;" parent="1" vertex="1">
<mxGeometry x="670" y="187.5" width="80" height="212.5" as="geometry" />
</mxCell>
<mxCell id="GARBAzdv9NtNetveAKvq-19" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;flipH=1;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;direction=south;strokeColor=#888888;fontColor=#888888;" vertex="1" parent="1">
<mxGeometry x="560" y="150" width="80" height="20" as="geometry" />
</mxCell>
<mxCell id="GARBAzdv9NtNetveAKvq-21" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;rounded=0;strokeColor=#888888;fontColor=#888888;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="600" y="430" as="sourcePoint" />
<mxPoint x="599.5" y="170" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="GARBAzdv9NtNetveAKvq-22" value="Communicates over&lt;br&gt;public internet" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontFamily=Verdana;fontColor=#888888;" vertex="1" parent="1">
<mxGeometry x="530" y="110" width="140" height="40" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "techsquawks",
"devDependencies": {
"@types/node": "^10.0.0",
"embedme": "^1.22.0",
"embedme": "^1.22.1",
"typescript": "^5.1.3"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const loginProfile = new aws.iam.UserLoginProfile("techsquawks-user-login-profil
passwordLength: 15,
passwordResetRequired: true
});
export const password = loginProfile.password;
exports.password = loginProfile.password;

```
{{% /tab %}}
Expand Down Expand Up @@ -111,8 +111,8 @@ from pulumi_aws import iam
user = iam.User("techsquawks-user", name="techsquawks-user")
login_profile = iam.UserLoginProfile("techsquawks-user-login-profile",
user=user.name,
passwordLength=15,
passwordResetRequired=True
password_length=15,
password_reset_required=True
);

pulumi.export('password', login_profile.password)
Expand Down Expand Up @@ -151,28 +151,22 @@ import (

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create IAM user with long-lived access credentials
user1, err := iam.NewUser(ctx, "techsquawks-user1", &iam.UserArgs{
Name: pulumi.String("techsquawks-user1"),
Path: pulumi.String("/example/path/1/"),
})
if err != nil {
return err
}
user2, err := iam.NewUser(ctx, "techsquawks-user2", &iam.UserArgs{
Name: pulumi.String("techsquawks-user2"),
Path: pulumi.String("/example/path/2/"),
// Create IAM user with password/console credentials
user, err := iam.NewUser(ctx, "techsquawks-user", &iam.UserArgs{
Name: pulumi.String("techsquawks-user"),
})
if err != nil {
return err
}
user2a, err := iam.NewUser(ctx, "techsquawks-user2a", &iam.UserArgs{
Name: pulumi.String("techsquawks-user2a"),
Path: pulumi.String("/example/path/2/"),
loginProfile, err := iam.NewUserLoginProfile(ctx, "loginProfile", &iam.UserLoginProfileArgs{
User: user.Name,
PasswordLength: pulumi.Int(15),
PasswordResetRequired: pulumi.Bool(true),
})
if err != nil {
return err
}
ctx.Export("password", loginProfile.Password)
return nil
})
}
Expand Down
12 changes: 6 additions & 6 deletions web/content/cloud_computing/aws/iam/identities/users/paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ import pulumi
from pulumi_aws import iam

# Create IAM user with long-lived access credentials
user1 = iam.User("techsquawks-user", name="techsquawks-user1", path="/example/path/1/")
user2 = iam.User("techsquawks-user", name="techsquawks-user2", path="/example/path/2/")
user2a = iam.User("techsquawks-user", name="techsquawks-user2a", path="/example/path/2/")
user1 = iam.User("techsquawks-user-1", name="techsquawks-user1", path="/example/path/1/")
user2 = iam.User("techsquawks-user-2a", name="techsquawks-user2", path="/example/path/2/")
user2a = iam.User("techsquawks-user-2b", name="techsquawks-user2a", path="/example/path/2/")

```
{{% /tab %}}
Expand Down Expand Up @@ -150,21 +150,21 @@ import (
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create IAM user with long-lived access credentials
user1, err := iam.NewUser(ctx, "techsquawks-user1", &iam.UserArgs{
_, err := iam.NewUser(ctx, "techsquawks-user1", &iam.UserArgs{
Name: pulumi.String("techsquawks-user1"),
Path: pulumi.String("/example/path/1/"),
})
if err != nil {
return err
}
user2, err := iam.NewUser(ctx, "techsquawks-user2", &iam.UserArgs{
_, err = iam.NewUser(ctx, "techsquawks-user2", &iam.UserArgs{
Name: pulumi.String("techsquawks-user2"),
Path: pulumi.String("/example/path/2/"),
})
if err != nil {
return err
}
user2a, err := iam.NewUser(ctx, "techsquawks-user2a", &iam.UserArgs{
_, err = iam.NewUser(ctx, "techsquawks-user2a", &iam.UserArgs{
Name: pulumi.String("techsquawks-user2a"),
Path: pulumi.String("/example/path/2/"),
})
Expand Down
4 changes: 2 additions & 2 deletions web/content/containers/Docker/_index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: Docker
draft: true
draft: false
chapter: true
weight: 4
---

# Docker

Developing containerized applications
Developing containerized applications within the Docker ecosystem.
6 changes: 3 additions & 3 deletions web/content/containers/Docker/bind_mount.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Bind Mounts
draft: false
chapter: false
draft: true
chapter: true
weight: 11
---
---
6 changes: 0 additions & 6 deletions web/content/containers/Docker/containers.md

This file was deleted.

Loading

0 comments on commit 5fe45a0

Please sign in to comment.