aboutsummaryrefslogtreecommitdiff
path: root/examples/example1.sh
blob: cc42e7cf70d95b5c905fe49645bac43737dd0fed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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 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
docker images | grep '18.04'