diff options
| author | mo khan <mo.khan@gmail.com> | 2020-06-10 16:50:24 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-06-10 16:50:24 -0600 |
| commit | 7263a3edf03b84abbdace78dd797d9184812b7db (patch) | |
| tree | 06236714452db5b48c0a804c018bf8d98e2047a6 | |
initial commit
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | Pipfile | 12 | ||||
| -rw-r--r-- | Pipfile.lock | 78 | ||||
| -rw-r--r-- | README.md | 176 | ||||
| -rw-r--r-- | examples/001/Dockerfile | 4 | ||||
| -rw-r--r-- | examples/001/hello.rb | 3 |
6 files changed, 276 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e780f3e --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +run: + pipenv install + pipenv run lookatme --theme=dark --style=vim --live README.md @@ -0,0 +1,12 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +lookatme = "*" + +[requires] +python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..82d200c --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,78 @@ +{ + "_meta": { + "hash": { + "sha256": "e708a544db04c52d208589e7f4eb0ec594971e0ce0f178e12f0ff8502a023ff3" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "click": { + "hashes": [ + "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", + "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" + ], + "version": "==7.1.2" + }, + "lookatme": { + "hashes": [ + "sha256:dabf49245ecca382cb3b031166559ed0c96683bd5a6043be7a019b8d5493cfa9" + ], + "index": "pypi", + "version": "==1.2.0" + }, + "marshmallow": { + "hashes": [ + "sha256:35ee2fb188f0bd9fc1cf9ac35e45fd394bd1c153cee430745a465ea435514bd5", + "sha256:9aa20f9b71c992b4782dad07c51d92884fd0f7c5cb9d3c737bea17ec1bad765f" + ], + "version": "==3.6.1" + }, + "mistune": { + "hashes": [ + "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e", + "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4" + ], + "version": "==0.8.4" + }, + "pygments": { + "hashes": [ + "sha256:647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44", + "sha256:ff7a40b4860b727ab48fad6360eb351cc1b33cbf9b15a0f689ca5353e9463324" + ], + "version": "==2.6.1" + }, + "pyyaml": { + "hashes": [ + "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97", + "sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76", + "sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2", + "sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648", + "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf", + "sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f", + "sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2", + "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee", + "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d", + "sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c", + "sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a" + ], + "version": "==5.3.1" + }, + "urwid": { + "hashes": [ + "sha256:0896f36060beb6bf3801cb554303fef336a79661401797551ba106d23ab4cd86" + ], + "version": "==2.1.0" + } + }, + "develop": {} +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..61f6caa --- /dev/null +++ b/README.md @@ -0,0 +1,176 @@ +--- +title: Developing with Docker +author: gitlab.com/xlgmokha/developing-with-docker +date: 2020-06-10 +--- + +# Developing with Docker + +Mo Khan, Backend Engineer + +Composition Analysis, GitLab + +https://gitlab.com/xlgmokha + +Inspired by: gitlab-org/gitlab#216082 + +# Agenda + +* Build (build) +* Start/Stop container (ps, start, stop) +* Getting a shell (run vs exec) +* Analyzing an image (dive, docker layers) +* Shrinking an image (compression, discuss the trade offs of having more v. less layers) +* Sharing an image (push, pull, authn) + +# Definitions + +* Image: is like a class +* Container: is like an instance of a class (i.e. object) + +# Definitions - Image/Container + +* Person is a class definition +* "you" and "mo" are instances of the class Person +* instances of person can interact with one another + +```ruby +class Person + def fist_bump(other_person) + end +end + +mo = Person.new +you = Person.new + +mo.first_bump(you) +``` + +# Definitions + +Registry: stores images and makes them available to others + +For example: + +* https://index.docker.io +* https://registry.gitlab.com + +```bash +curl -s -i https://index.docker.io/v2/alpine/tags/list +``` + +# Docker - Architecture + +```plantuml + +``` + +https://docs.docker.com/get-started/overview/#docker-architecture + +# Dockerfile + +A minimal Dockerfile: + +```file +path: examples/001/Dockerfile +relative: true +lang: docker +``` + +https://docs.docker.com/engine/reference/builder/ + +# Dockerfile - FROM + +> Initializes a build stage and sets a Base Image. + +In this example the base image is alpine:latest. +By default this image will be fetched from the default Docker registry. +https://index.docker.io/ + +```file +path: examples/001/Dockerfile +relative: true +lang: docker +lines: + start: 0 + end: 1 +``` + +# Dockerfile - COPY + +Copy "hello.rb" from the host to +"/usr/local/bin/hello" within the Docker image. + +```file +path: examples/001/Dockerfile +relative: true +lang: docker +lines: + start: 1 + end: 2 +``` + +```terminal8 +tree ./examples/001 +``` + +# Dockerfile - RUN + +RUN a command from within the image and make "hello" executable. + +```file +path: examples/001/Dockerfile +relative: true +lang: docker +lines: + start: 2 + end: 3 +``` + +# Dockerfile - CMD + +Set the default command to run when the docker image +is launched as a container. + +```file +path: examples/001/Dockerfile +relative: true +lang: docker +lines: + start: 2 + end: 3 +``` + +# docker build + +```terminal32 +bash -il +``` + +# docker ps + +# docker start + +# docker stop + +# docker run + +# docker exec + +# dive + +* Describe layers +* Downloading multiple layers in parallel vs 1 large layer + +# Compression (zstd) + +More layers == more parallel download +Smaller layers == faster downloads + +# Distribution + +# docker push + +# docker pull + +# docker login diff --git a/examples/001/Dockerfile b/examples/001/Dockerfile new file mode 100644 index 0000000..f5f827d --- /dev/null +++ b/examples/001/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:latest +COPY hello.rb /usr/local/bin/hello +RUN chmod +x /usr/local/bin/hello +CMD ["hello"] diff --git a/examples/001/hello.rb b/examples/001/hello.rb new file mode 100644 index 0000000..0a6e058 --- /dev/null +++ b/examples/001/hello.rb @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby + +puts "Hello World" |
