aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/example1.sh8
-rwxr-xr-xexamples/example2.sh2
-rwxr-xr-xexamples/example3/example3.sh2
-rw-r--r--examples/example4/Dockerfile5
-rwxr-xr-xexamples/example4/example4.sh22
-rwxr-xr-xexamples/example5.sh28
6 files changed, 65 insertions, 2 deletions
diff --git a/examples/example1.sh b/examples/example1.sh
index d441d9a..cc42e7c 100755
--- a/examples/example1.sh
+++ b/examples/example1.sh
@@ -16,6 +16,14 @@
set -exuo pipefail
# Run a container
+# Time the docker command tells us how long it took
+# --rm will remove the container after it's done executing
+# -it is for running the docker process interactively in our
+# current terminal vs running it as a daemon.
+# ubuntu:18.04 is the image we want to use, if we don't have
+# the image downloaded then docker will automatically try
+# to get it from docker hub
+# The remainder is the command we're passing to the container
time docker run --rm -it ubuntu:18.04 /bin/bash -c 'echo Hello World'
# Show size of docker container
diff --git a/examples/example2.sh b/examples/example2.sh
index ab4faff..e5d95c0 100755
--- a/examples/example2.sh
+++ b/examples/example2.sh
@@ -15,4 +15,4 @@
set -exuo pipefail
# Run a container
-docker run --rm -it ubuntu:18.04 /bin/bash -c date "$@"
+docker run --rm -it ubuntu:18.04 /bin/bash -c "date $*"
diff --git a/examples/example3/example3.sh b/examples/example3/example3.sh
index b1676a4..a57b368 100755
--- a/examples/example3/example3.sh
+++ b/examples/example3/example3.sh
@@ -19,4 +19,4 @@ set -exuo pipefail
docker build -t vim_image .
# Run the image
-docker run --rm -it -v "$(pwd)":/usr/src/app vim_image /bin/bash -c vim
+docker run --rm -it -v "$(pwd)":/usr/src/app vim_image /bin/bash -c "vim $*"
diff --git a/examples/example4/Dockerfile b/examples/example4/Dockerfile
new file mode 100644
index 0000000..a13c3cc
--- /dev/null
+++ b/examples/example4/Dockerfile
@@ -0,0 +1,5 @@
+FROM python:3
+
+RUN pip3 install babysploit
+
+WORKDIR /usr/src/app
diff --git a/examples/example4/example4.sh b/examples/example4/example4.sh
new file mode 100755
index 0000000..3029c59
--- /dev/null
+++ b/examples/example4/example4.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 baby_sploit .
+
+# Run the image
+docker run --rm -it -v "$(pwd)":/usr/src/app baby_sploit /bin/bash -c "babysploit $*"
diff --git a/examples/example5.sh b/examples/example5.sh
new file mode 100755
index 0000000..aaaff17
--- /dev/null
+++ b/examples/example5.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# vim: set filetype=sh
+#
+# Author: Cody Hiar
+# Date: 2019-01-15
+#
+# Description: How to run chrom containized
+#
+# 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
+
+# Error with container opening socket
+# https://github.com/jessfraz/dockerfiles/issues/4
+xhost local:root
+
+# Launch spotify in a container
+docker run -it \
+ --rm \
+ -v /tmp/.X11-unix:/tmp/.X11-unix \
+ -e DISPLAY=unix"$DISPLAY" \
+ --device /dev/snd \
+ --name spotify \
+ jess/spotify