summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-06-10 21:07:44 -0600
committermo khan <mo.khan@gmail.com>2020-06-10 21:07:44 -0600
commit0860d075d1a3e939ce1a6d4d9de96ea227333346 (patch)
treee3a8c918cdc9145761892e92f2a31397b53ca0bf
parent6f65e7fa18a406c5b233d7d692186b302d594971 (diff)
Compare large and small images
-rw-r--r--README.md77
-rw-r--r--examples/001/dive-exec.sh4
-rw-r--r--examples/002/Dockerfile1
-rw-r--r--examples/003/Dockerfile5
-rw-r--r--examples/003/run.sh8
5 files changed, 55 insertions, 40 deletions
diff --git a/README.md b/README.md
index 5b91e18..11e64e3 100644
--- a/README.md
+++ b/README.md
@@ -107,29 +107,29 @@ curl -s -i https://registry-1.docker.io/v2/alpine/tags/list
# Architecture
```text
- ----------
- | Client |
- ----------
- | build |
- | pull |
- | run |
- ----------
- | (tcp/unix socket)
- V
- ---------------
- | Docker Host |
- ---------------
- | Daemon |
- | Containers |
- | Images |
- --------------
- | A
- V |
- ------------
- | Registry |
- ------------
- | Images |
- ------------
+ ----------
+ | Client |
+ ----------
+ | build |
+ | pull |
+ | run |
+ ----------
+ | (tcp/unix socket)
+ V
+ ---------------
+ | Docker Host |
+ ---------------
+ | Daemon |
+ | Containers |
+ | Images |
+ --------------
+ | A
+ V |
+ ------------
+ | Registry |
+ ------------
+ | Images |
+ ------------
```
https://docs.docker.com/get-started/overview/#docker-architecture
@@ -140,7 +140,7 @@ https://docs.docker.com/get-started/overview/#docker-architecture
$ curl --unix-socket /var/run/docker.sock http://localhost/images/json
```
-```terminal16
+```terminal32
curl -i --unix-socket /var/run/docker.sock http://localhost/images/json
```
@@ -154,13 +154,13 @@ docker version
# $ docker image ls
-```terminal8
+```terminal32
docker image ls --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}"
```
# $ docker ps
-```terminal8
+```terminal32
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Status}}"
```
@@ -281,7 +281,7 @@ https://github.com/wagoodman/dive
* Allows investigating files that are added/removed/changed in each layer
```terminal32
-bash examples/001/dive-exec.sh
+bash examples/001/dive-exec.sh developing-with-docker
```
# Compression
@@ -289,7 +289,7 @@ bash examples/001/dive-exec.sh
* More layers == more parallel downloads
* Smaller layers == faster downloads per layer
-```terminal16
+```terminal32
bash -i examples/001/docker-large-download.sh
```
@@ -307,7 +307,7 @@ docker build -t big-image:latest examples/002/
# docker image ls
-```terminal8
+```terminal32
docker image ls --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}"
```
@@ -334,16 +334,29 @@ lang: sh
docker build -t small-image:latest examples/003/
```
+# dive small-image:latest
+
+```terminal32
+bash examples/001/dive-exec.sh small-image
+```
+
+# docker run -it small-image:latest
+
+```terminal32
+docker run -it small-image:latest
+```
+
# docker image ls
-```terminal8
-docker image ls --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}"
+```terminal32
+docker image ls --format "table {{.ID}}\t{{.Tag}}\t{{.Size}}"
```
+
# Summary
* Keep each layer small
-* More layers means more parallel downloads
+* More layers provides opportunity for more parallel downloads
# Fin
diff --git a/examples/001/dive-exec.sh b/examples/001/dive-exec.sh
index a14c43d..68de99d 100644
--- a/examples/001/dive-exec.sh
+++ b/examples/001/dive-exec.sh
@@ -1,6 +1,8 @@
#!/bin/sh
set -e
-image_id="$(docker image ls developing-with-docker | awk '{ print $3 }' | grep -v REPO | tail -n1)"
+
+name="$1"
+image_id="$(docker image ls "$name" | awk '{ print $3 }' | grep -v REPO | tail -n1)"
echo "$ dive $image_id"
dive "$image_id"
diff --git a/examples/002/Dockerfile b/examples/002/Dockerfile
index f875871..304abfb 100644
--- a/examples/002/Dockerfile
+++ b/examples/002/Dockerfile
@@ -5,4 +5,3 @@ RUN apt-get install -y git
RUN apt-get install -y ruby
RUN apt-get install -y zstd
RUN git clone --verbose https://github.com/spandx/cache.git /opt/db
-WORKDIR /opt
diff --git a/examples/003/Dockerfile b/examples/003/Dockerfile
index 35b83ea..a722743 100644
--- a/examples/003/Dockerfile
+++ b/examples/003/Dockerfile
@@ -1,8 +1,9 @@
FROM debian:stable-slim
ENV PACKAGES git ruby zstd
-RUN apt-get update -y --no-install-recommends $PACKAGES \
+RUN apt-get update -y \
+ && apt-get install -y --no-install-recommends $PACKAGES \
&& git clone https://github.com/spandx/cache.git /opt/db \
&& tar --use-compress-program zstd -cf /opt/db.tar.zst /opt/db \
&& rm -fr /opt/db
COPY run.sh /run.sh
-CMD ['/run.sh']
+ENTRYPOINT ["/run.sh"]
diff --git a/examples/003/run.sh b/examples/003/run.sh
index db1f294..bf50deb 100644
--- a/examples/003/run.sh
+++ b/examples/003/run.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-set -ex
+set -e
+echo "[$(date +s)] Inflating /opt/db.tar.zst"
tar -xf /opt/db.tar.zst
-
-cd /opt/db/.index
-sh
+echo sh "$@"
+sh "$@"