diff options
-rwxr-xr-x | examples/example5.sh | 3 | ||||
-rw-r--r-- | examples/example6/docker-compose.yml | 23 | ||||
-rwxr-xr-x | examples/example6/example6.sh | 18 | ||||
-rwxr-xr-x | examples/example7/example7.sh | 18 | ||||
-rw-r--r-- | examples/example8/Dockerfile | 20 | ||||
-rw-r--r-- | examples/example8/docker-compose.yml | 14 | ||||
-rw-r--r-- | examples/example8/plugins.txt | 104 | ||||
-rw-r--r-- | slides.md | 114 |
8 files changed, 306 insertions, 8 deletions
diff --git a/examples/example5.sh b/examples/example5.sh index aaaff17..64437e1 100755 --- a/examples/example5.sh +++ b/examples/example5.sh @@ -23,6 +23,7 @@ docker run -it \ --rm \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e DISPLAY=unix"$DISPLAY" \ - --device /dev/snd \ + --device /dev/snd:/dev/snd \ --name spotify \ + --user root \ jess/spotify diff --git a/examples/example6/docker-compose.yml b/examples/example6/docker-compose.yml new file mode 100644 index 0000000..082697c --- /dev/null +++ b/examples/example6/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.1' + +services: + + wordpress: + image: wordpress + restart: always + ports: + - 8000:80 + environment: + WORDPRESS_DB_HOST: db + WORDPRESS_DB_USER: exampleuser + WORDPRESS_DB_PASSWORD: examplepass + WORDPRESS_DB_NAME: exampledb + + db: + image: mysql:5.7 + restart: always + environment: + MYSQL_DATABASE: exampledb + MYSQL_USER: exampleuser + MYSQL_PASSWORD: examplepass + MYSQL_RANDOM_ROOT_PASSWORD: '1' diff --git a/examples/example6/example6.sh b/examples/example6/example6.sh new file mode 100755 index 0000000..9078da1 --- /dev/null +++ b/examples/example6/example6.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Cody Hiar +# Date: 2019-01-15 +# +# Description: run docker-compose 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 the compose file +docker-compose up diff --git a/examples/example7/example7.sh b/examples/example7/example7.sh new file mode 100755 index 0000000..38cbbbc --- /dev/null +++ b/examples/example7/example7.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Cody Hiar +# Date: 2019-01-15 +# +# Description: User cookiecutter to create templated docker project +# +# 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 cookiecutter +cookiecutter https://github.com/thornycrackers/cookiecutter_docker diff --git a/examples/example8/Dockerfile b/examples/example8/Dockerfile new file mode 100644 index 0000000..fee10e9 --- /dev/null +++ b/examples/example8/Dockerfile @@ -0,0 +1,20 @@ +FROM jenkins/jenkins:lts + +USER root + +RUN apt-get update && apt-get -y install \ + build-essential \ + libltdl-dev \ + sudo \ + rsync + +RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers + +# Install Plugins +COPY plugins.txt /usr/share/jenkins/ref/plugins.txt +RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt + +# Prevent plugin install banner, we've pre-installed our plugins +RUN echo 2.0 > /usr/share/jenkins/ref/jenkins.install.UpgradeWizard.state + +USER jenkins diff --git a/examples/example8/docker-compose.yml b/examples/example8/docker-compose.yml new file mode 100644 index 0000000..dd8cc62 --- /dev/null +++ b/examples/example8/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' +services: + backend: + build: ./ + network_mode: "bridge" + container_name: jenkins_docker + image: thornycrackers/jenkins_docker + ports: + - "8080:8080" + - "50000:50000" + volumes: + - /var/jenkins_home:/var/jenkins_home + - /var/run/docker.sock:/var/run/docker.sock + - /usr/bin/docker:/usr/bin/docker diff --git a/examples/example8/plugins.txt b/examples/example8/plugins.txt new file mode 100644 index 0000000..37e62e1 --- /dev/null +++ b/examples/example8/plugins.txt @@ -0,0 +1,104 @@ +ace-editor:1.1 +antisamy-markup-formatter:1.5 +apache-httpcomponents-client-4-api:4.5.5-3.0 +authentication-tokens:1.3 +blueocean-autofavorite:1.2.2 +blueocean-bitbucket-pipeline:1.10.1 +blueocean-commons:1.10.1 +blueocean-config:1.10.1 +blueocean-core-js:1.10.1 +blueocean-dashboard:1.10.1 +blueocean-display-url:2.2.0 +blueocean-events:1.10.1 +blueocean-git-pipeline:1.10.1 +blueocean-github-pipeline:1.10.1 +blueocean-i18n:1.10.1 +blueocean-jira:1.10.1 +blueocean-jwt:1.10.1 +blueocean-personalization:1.10.1 +blueocean-pipeline-api-impl:1.10.1 +blueocean-pipeline-editor:1.10.1 +blueocean-pipeline-scm-api:1.10.1 +blueocean-rest-impl:1.10.1 +blueocean-rest:1.10.1 +blueocean-web:1.10.1 +blueocean:1.10.1 +bouncycastle-api:2.17 +branch-api:2.1.2 +build-timeout:1.19 +cloudbees-bitbucket-branch-source:2.3.0 +cloudbees-folder:6.7 +command-launcher:1.3 +credentials-binding:1.17 +credentials:2.1.18 +display-url-api:2.3.0 +docker-commons:1.13 +docker-workflow:1.17 +durable-task:1.28 +email-ext:2.63 +favorite:2.3.2 +git-client:2.7.5 +git-server:1.7 +git:3.9.1 +github-api:1.95 +github-branch-source:2.4.1 +github:1.29.3 +handlebars:1.1.1 +handy-uri-templates-2-api:2.1.6-1.0 +htmlpublisher:1.17 +jackson2-api:2.9.8 +jdk-tool:1.2 +jenkins-design-language:1.10.1 +jira:3.0.5 +jquery-detached:1.2.1 +jsch:0.1.54.2 +junit:1.26.1 +ldap:1.20 +locale:1.4 +lockable-resources:2.3 +mailer:1.23 +matrix-auth:2.3 +matrix-project:1.13 +mercurial:2.4 +momentjs:1.1.1 +pam-auth:1.4 +pipeline-build-step:2.7 +pipeline-github-lib:1.0 +pipeline-graph-analysis:1.9 +pipeline-input-step:2.9 +pipeline-milestone-step:1.3.1 +pipeline-model-api:1.3.4 +pipeline-model-declarative-agent:1.1.1 +pipeline-model-definition:1.3.4 +pipeline-model-extensions:1.3.4 +pipeline-rest-api:2.10 +pipeline-stage-step:2.3 +pipeline-stage-tags-metadata:1.3.4 +pipeline-stage-view:2.10 +plain-credentials:1.5 +publish-over-ssh:1.20.1 +pubsub-light:1.12 +resource-disposer:0.12 +scm-api:2.3.0 +script-security:1.49 +sse-gateway:1.17 +ssh-agent:1.17 +ssh-credentials:1.14 +ssh-slaves:1.29.4 +ssh:2.6.1 +structs:1.17 +timestamper:1.8.10 +token-macro:2.5 +variant:1.1 +workflow-aggregator:2.6 +workflow-api:2.33 +workflow-basic-steps:2.13 +workflow-cps-global-lib:2.12 +workflow-cps:2.61 +workflow-durable-task-step:2.27 +workflow-job:2.31 +workflow-multibranch:2.20 +workflow-scm-step:2.7 +workflow-step-api:2.17 +workflow-support:3.0 +ws-cleanup:0.37 @@ -32,7 +32,8 @@ * Help build a mental model of Docker * Introduce Docker basics -* Give some working examples for possibilites +* Give some working examples +* Show potential of what's possible -> My Assumptions <- ==================== @@ -92,7 +93,7 @@ Seconds vs Minutes -> Pfffft Let's see it <- ========================= -example1.sh demo +example1 demo - Run script - Explain commands @@ -131,7 +132,7 @@ this we will! -> Let's dockerize the 'date' command <- ======================================== -example2.sh demo +example2 demo - show `date` command - show script with docker command explain '$@' args @@ -162,7 +163,7 @@ run an application. -> Let's dockerize Vim <- ========================= -example3.sh demo +example3 demo - Show Dockerfile - Show script, explain docker build @@ -205,7 +206,7 @@ Now we don't have to pick tools based on their languages. -> Let's dockerize Babysploit <- ================================ -example4.sh demo +example4 demo - Babysploit provides own container, we'll try our own - Show Dockerfile and script @@ -236,7 +237,7 @@ So far we've only been working with simple binaries on the command line but docker is capable of much, much more. How about GUI aplications? -* Note: This is for linux only, sorry mac/windows +* Note: This example is for linux users only * ref: https://blog.jessfraz.com/post/ * docker-containers-on-the-desktop/ @@ -245,7 +246,7 @@ about GUI aplications? -> Let's dockerize Spotify <- ============================= -example5.sh demo +example5 demo - Explain how display can be shared with volumes - Run spotify @@ -259,3 +260,102 @@ Docker compose is a tool for defining multi container environments that allow us to create a repeatable infrastructure setup so that we can build complex environments that have complex requirements. + +------------------------------------------------- + +-> Setting up a WordPress site <- +================================= + +example6 demo + +- Show and explain compose.yml file +- Bring up site and show in browser + +------------------------------------------------- + +-> Automating Docker commands with Makefile <- +============================================== + +Typing out the long Docker commands can become very tedious. +My recommended approach to solving this to use a `Makefile` +to automate building and running the containers. Once you +start integrating with CI pipeline you can use the Makefiles +to help you ensure that your project runs correcly +everywhere. + +------------------------------------------------- + +-> Create a Templated Project with CookieCutter <- +================================================== + +example7 demo + +- Run the command to generate project +- Explain files + +------------------------------------------------- + +And now for my final trick... + +------------------------------------------------- + +-> Docker inside Docker <- +========================== + +What about running docker inside of a docker container? +Let's set up a Jenkins server that will mount the hosts +docker binary and socket so that it can build containers +while itself being inside a container + +------------------------------------------------- + +-> Ow, my head! <- +================== + ++----------------------------------+ +| Host +----------------+ | +| | | | +| | | | +| binary <--------> Jenkins | | +| | | | +| socket <--------> | | +| | | | +| +----------------+ | +| | +| my_image_1 | +| my_image_2 | +| | +| | ++----------------------------------+ + +------------------------------------------------- + +-> Dockerception with Jenkins <- +================================ + +example8 demo + +- Show and explain how sharing works +- Show working example + +------------------------------------------------- + +-> Hosting <- +============= + +- Rancher +- Kubernetes +- Docker Swarm +- Portainer + +------------------------------------------------- + +-> Additional Resources <- +========================== + +(Docker for Beginners) +https://docker-curriculum.com/ +(Playground for using Docker) +https://labs.play-with-docker.com/ +(Dockerized Desktop Apps) +https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ |