aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2019-01-12 17:05:29 -0700
committerCody Hiar <codyfh@gmail.com>2019-01-12 17:05:29 -0700
commit8f7de74cd6fb4317771586c65b43f8a6e4d85f26 (patch)
tree4f21c02b1d83853103fd0238b36e9e1596eb59ef /examples
Some working files
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/example1.sh22
-rwxr-xr-xexamples/example2.sh18
-rw-r--r--examples/example3/Dockerfile5
-rwxr-xr-xexamples/example3/example3.sh22
4 files changed, 67 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