Docker for Fun and Profit

Kel Cecil
Kel CecilSoftware Engineer at ListHub
Docker for Fun
and Profit
Kel Cecil
@praisechaos
So, what’s Docker?
❖ Docker is an open platform that allows developers and
system administrators to abstract their applications for
multiple platforms.
❖ We’ll focus our attention on Docker Engine today.
Disrupt Chuck Norris Quotes!
❖ We’re going to containerize and
run our simple app.
❖ Find the app and Dockerfile at:
https://github.com/kelcecil/dock
er-techfest15
Creating our Docker Image
❖ Start with building a Dockerfile.
❖ Image contains our app, dependencies and other
required items.
❖ Images are read-only.
❖ Encourages immutable infrastructure!
Docker Build Context
❖ Everything in context directory is sent when performing
build.
❖ Anything in this context directory can be added to the
image.
Docker for Fun and Profit
FROM specifies an image in which
we’ll start building from.
Images You’ll Want to
Remember
❖ Images for Linux distros you know and love:
❖ ubuntu, fedora, debian
❖ Images for languages to get going quickly:
❖ golang, ruby, java
❖ My personal favorite:
❖ gliderlabs/alpine
MAINTAINER sets metadata
information on who keeps the image
up to date.
USER sets the user to execute RUN
and CMD commands as.
RUN simply runs a shell command.
Easy.
COPY copies files from the Docker
context into the destination folder on
image.
Never allow your application to run as
root. Be sure to switch to a different
user for executing your app.
WORKDIR changes the current
working directory.
CMD sets the default command we’ll
run if we don’t provide with docker
run.
Building an Image From a
Dockerfile
docker build -t chucksay:latest <context_dir>
❖ -t specifies the tag name for the image.
❖ <context_dir>
❖ Directory of Dockerfile and build context
Docker for Fun and Profit
Looking At Our Image
Running Our Webservice in a
Container
docker run -d -p 8080:4567 chucksay:latest
❖ -d to run detached
❖ -p specifies our ports internal to the container (right of
the colon) and externally (left of the colon).
❖ “chucksay” is our tag name
Running Our Container
Interactively
docker run -it -p 8080:4567 chucksay:latest
/bin/bash
❖ -it lets us interact with the container.
❖ -i is the interactive flag.
❖ -t allocates a pseudo-TTY
❖ Override the CMD we provided in the Dockerfile.
❖ Exiting bash stops the container.
Docker Compose (fig)
❖ Keep container parameters in a
JSON or YAML file.
❖ Build or run your application
quite easily:
❖ docker-compose up -d
Looking at Running
Containers
docker ps
❖ Container ID
❖ Image
❖ Command
❖ Time since creation
❖ Status
❖ Ports
❖ Container Names
Stopping Our Webservice
Container
docker stop <container_id>
❖ <container_id> can be:
❖ Container ID
❖ Container Name
What can we use containers
for?
Deploying Applications
❖ Package your application code, language specific
dependencies, and system dependencies into a
container.
❖ Push your images into a remote Docker repository.
❖ Pull them into production, your box, or where ever.
Docker Repository
❖ Deploying a registry yourself:
❖ https://docs.docker.com/registry/deploying/
http://hub.docker.com http://quay.io
Cluster Deployment
❖ Make orchestration easy with cluster management
technologies:
❖ Kubernetes (http://kubernetes.io)
❖ Deis (http://deis.io)
❖ Plenty more…
Try Docker for CI
❖ Try running for continuous integration tasks inside of a
container.
❖ Updating your CI environment is as easy as a simple
docker push.
❖ Prepare for different environment configurations by
pushing additional images with tags.
❖ Pull the CI environment to developers boxes for easy
access.
Sharing With The World
❖ A few additional ideas to consider trying for your
continued Docker education.
❖ Working with containers and Docker is best way to
understand it.
Lowering the Barrier to Open
Source
❖ A hopeful open source developer or user needs an sane
environment that works.
❖ User might only be interested performing a quick build.
❖ Containerized development environment allows an easy
and quick start to the new developer.
Sharing Dotfiles
❖ dotfile repositories are plentiful on Github.
❖ Take someone else’s configuration for a spin!
❖ Share your own configuration for tech cred.
Thanks for playing along!
❖ Kel Cecil
❖ Twitter: @praisechaos
❖ http://www.kelcecil.com
1 of 32

Recommended

Scaling Docker Containers using Kubernetes and Azure Container Service by
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceBen Hall
804 views120 slides
Continuous Deployment with Jenkins on Kubernetes by
Continuous Deployment with Jenkins on KubernetesContinuous Deployment with Jenkins on Kubernetes
Continuous Deployment with Jenkins on KubernetesMatt Baldwin
3.8K views27 slides
Scaling docker with kubernetes by
Scaling docker with kubernetesScaling docker with kubernetes
Scaling docker with kubernetesLiran Cohen
2.4K views79 slides
Scaling Docker with Kubernetes by
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with KubernetesCarlos Sanchez
1.7K views50 slides
Deploying apps with Docker and Kubernetes by
Deploying apps with Docker and KubernetesDeploying apps with Docker and Kubernetes
Deploying apps with Docker and KubernetesDaniel Fenton
674 views12 slides
Achieving CI/CD with Kubernetes by
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with KubernetesRamit Surana
48.8K views37 slides

More Related Content

What's hot

Container Days Boston - Kubernetes in production by
Container Days Boston - Kubernetes in productionContainer Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in productionMike Splain
1.8K views36 slides
Kubernetes Node Deep Dive by
Kubernetes Node Deep DiveKubernetes Node Deep Dive
Kubernetes Node Deep DiveLei (Harry) Zhang
2.8K views32 slides
Kubernetes intro public - kubernetes meetup 4-21-2015 by
Kubernetes intro   public - kubernetes meetup 4-21-2015Kubernetes intro   public - kubernetes meetup 4-21-2015
Kubernetes intro public - kubernetes meetup 4-21-2015Rohit Jnagal
3.3K views31 slides
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka by
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Mario Ishara Fernando
390 views48 slides
IPC16: A Practical Introduction to Kubernetes by
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes Robert Lemke
1.3K views49 slides
Kubernetes Hands-On Guide by
Kubernetes Hands-On GuideKubernetes Hands-On Guide
Kubernetes Hands-On GuideStratoscale
2.2K views47 slides

What's hot(20)

Container Days Boston - Kubernetes in production by Mike Splain
Container Days Boston - Kubernetes in productionContainer Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in production
Mike Splain1.8K views
Kubernetes intro public - kubernetes meetup 4-21-2015 by Rohit Jnagal
Kubernetes intro   public - kubernetes meetup 4-21-2015Kubernetes intro   public - kubernetes meetup 4-21-2015
Kubernetes intro public - kubernetes meetup 4-21-2015
Rohit Jnagal3.3K views
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka by Mario Ishara Fernando
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
IPC16: A Practical Introduction to Kubernetes by Robert Lemke
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes
Robert Lemke1.3K views
Kubernetes Hands-On Guide by Stratoscale
Kubernetes Hands-On GuideKubernetes Hands-On Guide
Kubernetes Hands-On Guide
Stratoscale2.2K views
Monitoring, Logging and Tracing on Kubernetes by Martin Etmajer
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
Martin Etmajer6.6K views
Kubernetes Architecture - beyond a black box - Part 2 by Hao H. Zhang
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
Hao H. Zhang2.5K views
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days by Carlos Sanchez
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2daysUsing Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Carlos Sanchez1.1K views
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart by Docker, Inc.
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Docker, Inc.20.9K views
Package your Java EE Application using Docker and Kubernetes by Arun Gupta
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
Arun Gupta27.1K views
Kubernetes architecture by Janakiram MSV
Kubernetes architectureKubernetes architecture
Kubernetes architecture
Janakiram MSV13.6K views
Tectonic Summit 2016: Kubernetes 1.5 and Beyond by CoreOS
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
CoreOS1.6K views
Kubelet with no Kubernetes Masters | DevNation Tech Talk by Red Hat Developers
Kubelet with no Kubernetes Masters | DevNation Tech TalkKubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers4.4K views
Docker storage designing a platform for persistent data by Docker, Inc.
Docker storage designing a platform for persistent dataDocker storage designing a platform for persistent data
Docker storage designing a platform for persistent data
Docker, Inc.3K views
Online Meetup: Why should container system / platform builders care about con... by Docker, Inc.
Online Meetup: Why should container system / platform builders care about con...Online Meetup: Why should container system / platform builders care about con...
Online Meetup: Why should container system / platform builders care about con...
Docker, Inc.3K views
Deep dive in container service discovery by Docker, Inc.
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discovery
Docker, Inc.1.5K views
Dockerizing Windows Server Applications by Ender Barillas and Taylor Brown by Docker, Inc.
Dockerizing Windows Server Applications by Ender Barillas and Taylor BrownDockerizing Windows Server Applications by Ender Barillas and Taylor Brown
Dockerizing Windows Server Applications by Ender Barillas and Taylor Brown
Docker, Inc.1.1K views
Configuration Management and Transforming Legacy Applications in the Enterpri... by Docker, Inc.
Configuration Management and Transforming Legacy Applications in the Enterpri...Configuration Management and Transforming Legacy Applications in the Enterpri...
Configuration Management and Transforming Legacy Applications in the Enterpri...
Docker, Inc.758 views

Similar to Docker for Fun and Profit

Docker, LinuX Container by
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX ContainerAraf Karsh Hamid
5.6K views71 slides
Docker for Deep Learning (Andrea Panizza) by
Docker for Deep Learning (Andrea Panizza)Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)MeetupDataScienceRoma
380 views24 slides
[@NaukriEngineering] Docker 101 by
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101Naukri.com
317 views41 slides
Docker presentation by
Docker presentationDocker presentation
Docker presentationShankar Chaudhary
4.8K views17 slides
Academy PRO: Docker. Part 2 by
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Binary Studio
352 views27 slides
Docker primer and tips by
Docker primer and tipsDocker primer and tips
Docker primer and tipsSamuel Chow
108 views52 slides

Similar to Docker for Fun and Profit(20)

[@NaukriEngineering] Docker 101 by Naukri.com
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
Naukri.com317 views
Academy PRO: Docker. Part 2 by Binary Studio
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
Binary Studio352 views
Docker primer and tips by Samuel Chow
Docker primer and tipsDocker primer and tips
Docker primer and tips
Samuel Chow108 views
Docker From Scratch by Giacomo Vacca
Docker From ScratchDocker From Scratch
Docker From Scratch
Giacomo Vacca15.4K views
Introduction to Docker - Learning containerization XP conference 2016 by XP Conference India
Introduction to Docker - Learning containerization  XP conference 2016Introduction to Docker - Learning containerization  XP conference 2016
Introduction to Docker - Learning containerization XP conference 2016
Academy PRO: Docker. Lecture 2 by Binary Studio
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
Binary Studio118 views
Running the Oracle SOA Suite Environment in a Docker Container by Guido Schmutz
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz7.2K views
Up and running with docker by Michelle Liu
Up and running with dockerUp and running with docker
Up and running with docker
Michelle Liu637 views
ContainerDayVietnam2016: Dockerize a small business by Docker-Hanoi
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
Docker-Hanoi498 views

Recently uploaded

The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
115 views25 slides
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院IttrainingIttraining
69 views8 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
48 views69 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
31 views23 slides
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
26 views29 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
50 views15 slides

Recently uploaded(20)

【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker48 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue31 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue26 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue37 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue60 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue28 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue81 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue84 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue64 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi139 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue55 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu28 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson126 views

Docker for Fun and Profit

  • 1. Docker for Fun and Profit Kel Cecil @praisechaos
  • 2. So, what’s Docker? ❖ Docker is an open platform that allows developers and system administrators to abstract their applications for multiple platforms. ❖ We’ll focus our attention on Docker Engine today.
  • 3. Disrupt Chuck Norris Quotes! ❖ We’re going to containerize and run our simple app. ❖ Find the app and Dockerfile at: https://github.com/kelcecil/dock er-techfest15
  • 4. Creating our Docker Image ❖ Start with building a Dockerfile. ❖ Image contains our app, dependencies and other required items. ❖ Images are read-only. ❖ Encourages immutable infrastructure!
  • 5. Docker Build Context ❖ Everything in context directory is sent when performing build. ❖ Anything in this context directory can be added to the image.
  • 7. FROM specifies an image in which we’ll start building from.
  • 8. Images You’ll Want to Remember ❖ Images for Linux distros you know and love: ❖ ubuntu, fedora, debian ❖ Images for languages to get going quickly: ❖ golang, ruby, java ❖ My personal favorite: ❖ gliderlabs/alpine
  • 9. MAINTAINER sets metadata information on who keeps the image up to date.
  • 10. USER sets the user to execute RUN and CMD commands as.
  • 11. RUN simply runs a shell command. Easy.
  • 12. COPY copies files from the Docker context into the destination folder on image.
  • 13. Never allow your application to run as root. Be sure to switch to a different user for executing your app.
  • 14. WORKDIR changes the current working directory.
  • 15. CMD sets the default command we’ll run if we don’t provide with docker run.
  • 16. Building an Image From a Dockerfile docker build -t chucksay:latest <context_dir> ❖ -t specifies the tag name for the image. ❖ <context_dir> ❖ Directory of Dockerfile and build context
  • 18. Looking At Our Image
  • 19. Running Our Webservice in a Container docker run -d -p 8080:4567 chucksay:latest ❖ -d to run detached ❖ -p specifies our ports internal to the container (right of the colon) and externally (left of the colon). ❖ “chucksay” is our tag name
  • 20. Running Our Container Interactively docker run -it -p 8080:4567 chucksay:latest /bin/bash ❖ -it lets us interact with the container. ❖ -i is the interactive flag. ❖ -t allocates a pseudo-TTY ❖ Override the CMD we provided in the Dockerfile. ❖ Exiting bash stops the container.
  • 21. Docker Compose (fig) ❖ Keep container parameters in a JSON or YAML file. ❖ Build or run your application quite easily: ❖ docker-compose up -d
  • 22. Looking at Running Containers docker ps ❖ Container ID ❖ Image ❖ Command ❖ Time since creation ❖ Status ❖ Ports ❖ Container Names
  • 23. Stopping Our Webservice Container docker stop <container_id> ❖ <container_id> can be: ❖ Container ID ❖ Container Name
  • 24. What can we use containers for?
  • 25. Deploying Applications ❖ Package your application code, language specific dependencies, and system dependencies into a container. ❖ Push your images into a remote Docker repository. ❖ Pull them into production, your box, or where ever.
  • 26. Docker Repository ❖ Deploying a registry yourself: ❖ https://docs.docker.com/registry/deploying/ http://hub.docker.com http://quay.io
  • 27. Cluster Deployment ❖ Make orchestration easy with cluster management technologies: ❖ Kubernetes (http://kubernetes.io) ❖ Deis (http://deis.io) ❖ Plenty more…
  • 28. Try Docker for CI ❖ Try running for continuous integration tasks inside of a container. ❖ Updating your CI environment is as easy as a simple docker push. ❖ Prepare for different environment configurations by pushing additional images with tags. ❖ Pull the CI environment to developers boxes for easy access.
  • 29. Sharing With The World ❖ A few additional ideas to consider trying for your continued Docker education. ❖ Working with containers and Docker is best way to understand it.
  • 30. Lowering the Barrier to Open Source ❖ A hopeful open source developer or user needs an sane environment that works. ❖ User might only be interested performing a quick build. ❖ Containerized development environment allows an easy and quick start to the new developer.
  • 31. Sharing Dotfiles ❖ dotfile repositories are plentiful on Github. ❖ Take someone else’s configuration for a spin! ❖ Share your own configuration for tech cred.
  • 32. Thanks for playing along! ❖ Kel Cecil ❖ Twitter: @praisechaos ❖ http://www.kelcecil.com

Editor's Notes

  1. Docker defines itself as open platform that allows developers and system administrators to abstract their applications for multiple platforms. Easy to have self-contained applications with dependencies from any sources. Apps with dependencies installed from debians repository can be ran on Fedora boxes with ease. Docker’s platform is growing over time with new additions like Swarm We’ll concentrate today on what most people think of when they think of Docker. Docker Engine.
  2. One of the best ways to understand containerization is to containerize an app. We’ll be containerizing a simple Sinatra web app with a single GET endpoint that just returns a Chuck Norris quote. Don’t worry about taking notes. You can find these slides and example files in this repo on Github. I’ll tweet out the link after the presentation, so just remember my twitter handle.
  3. Start containerizing our application by creating a Docker image. An image is a read-only file system containing our application code, dependencies, and anything else we might need. Images are what we share through Docker repositories. Their read-only nature encourages us to embrace the idea of immutable architecture.
  4. Let’s take a look at our app directory before we get into the Dockerfile. Our directory contains a Dockerfile, our Ruby script in a folder, a bash script to install Ruby, a YAML file (which we’ll discuss later), and a markdown README file. This directory is what we call the “build context” and is sent to the Docker daemon when we build our image. Everything in this directory and it’s descendants are sent to the Docker daemon. Aren’t necessary added to the Docker image. We’ll be specifically adding the files we need in our Dockerfile using commands I’ll show you in a few minutes.
  5. Here’s a full completed Dockerfile that creates our image to distribute our container. Let’s take a minute to take in how awesome this is. There’s few things going on, so let’s check this out step by step.
  6. FROM specifies an image from which we’ll build from. You can start with any image name or hash you like. Docker will pull the image from a remote registry if the the image isn’t already on your machine.
  7. Lots of images to use when selecting a base image. Images for distributions you already know: ubuntu, fedora, debian. Images for languages to get started in an environment quickly: golang, ruby, java My personal favorite image is Glider Lab’s Alpine Linux. Optimized to be incredibly small to save disk space and time when initially pulling and updating your images. Includes a package system to easily install anything you might need. Give it a try!
  8. Maintainer is just a simple line that includes some metadata for the image. You can safely omit this.
  9. USER sets the user we’ll be running RUN and CMD as. Docker best practices suggests to use root until you’re finished setting up your system dependencies to avoid potential complications with sudo and switching to another user for running your application.
  10. RUN executes a command. You can perform systems tasks or run shell scripts to get your image to where it needs to be to run your application. This step runs when you run docker build.
  11. ADD takes files and adds them into the image. The ADD command can also accept a URL or a TAR file that will be expanded when added into the image.
  12. COPY copies files from the Docker context into the destination folder on the image. Both COPY and RUN will both be executed when during docker build.
  13. Don’t forget. Don’t run your application as root.
  14. WORKDIR just sets the working directory for running applications. You’ll notice I take advantage of this to run Ruby’s bundler in the app’s directory.
  15. CMD sets the default command we’ll run if we don’t provide a command to run when invoking docker run. This can easily be override when we run our container, and it can be omitted now if we don’t want to provide a default.
  16. We now want to build our image from our Dockerfile. We’ll use the -t parameter to specify a tag name to apply to an image. Our final parameter is the directory of the Dockerfile and the build context. The directory will be sent to the Docker daemon to build our image.
  17. Here’s output from running Docker Build. Each line in Dockerfile is executed and an independent image is created. These images are called layers. These layer are put together when the container is created thanks to Docker’s Union File System. You’ll notice that every step in my output specifies that it’s using cache. Docker has heuristics built in to know when to rebuild your layers. Check out the Dockerfile Best Practices for more information on this works. Image caching is fantastic for reducing the layers needed to be rebuilt or transferred when updating an image. Translates to faster deploys for you!
  18. Check out the image we just built with docker images. We can see both our chucksay image as well as the debian image that we built from. We can also see our generated image ID.
  19. Let’s try running our webapp. We’ll use docker run to create and run our container. -d runs the container in a detached state that’s great for running web services. -p specifies our ports that we’ll be using to communicate with our app internal to the container and externally. Why do this? Might want to serve two apps that are both configured to serve over HTTP port 8080. We obviously can’t do that. We don’t want to change our app configuration for each container to serve over a different port. We can simply tell Docker the port the application will talk to inside the container and map it to a port that will be exposed on the server. This enables much easier multi-tenancy on servers without per-container application configuration changes. We end with specifying our image and tag name.
  20. We can run our container interactively to play around if we’d like. For example, let’s start bash and play around in our image. We can use -it. This is actually two parameters that both enable interactivity through -i and create a pseudo-TTY interface with -t. We again specify the image we want to run. We override the CMD we provided in the Dockerfile to run /bin/bash. Omitting as we saw earlier will let us use the default CMD.
  21. Typing out the docker run command can be more complex as continue to learn about advanced Docker features. Don’t always want to type out that docker run command. It can be a pain to share those instructions with others. Docker Compose can help you share parameters for containers to easily build or run your containers. A simple docker-compose YAML file is included in the example repository to try out!
  22. Apologize for the output being a bit too wide to display well. We can see containers that are currently running with some helpful formation- Container ID - A hash identifier uniquely identifying our running container. Image - The repository and version that is running in the container. Command - What is running inside the container Created - Time since creation. Status - An brief status of how our container is doing. Ports - A quick reference of what ports are being redirected (think back to our -p argument and rerouting port 8080 to 4567.) Names - An easy to remember name. You can assign this name, or Docker will generate one for you. Docker can generate some pretty amusing names.
  23. We can docker stop using what we saw from docker ps: container ID container name Sends a terminate signal to the command you run Will send a kill signal to the command if it doesn’t respond within 10 seconds (configurable).
  24. We’ve looked at how to build a simple container. Let’s be a little creative. Let’s talk about what we can do with containers.
  25. Deploying applications with docker is the first use case everyone considers when using Docker. The easiest way to share our Docker images is by pushing to a remote Docker and pulling it to your production box, developer station, or whatever you like.
  26. There are plenty of registry hosting services to try out! DockerHub is Docker’s official repository hosting. Host unlimited public containers Host one private container for free to try it out! Quay.io is CoreOS’s hosting service Host unlimited public containers Great support for teams! Both hosts provide cool features like automatic Dockerfile building on a repository push.
  27. You might find that you’d like an easier way to distribute and run your containerized processes as your container grows. There’s plenty of cluster orchestration tools for any style of deployment. I’ll mention two such tools now. Kubernetes is an descendant of Google’s Borg and intended to provide a process-like abstraction over a cluster of minions. It provides basic scheduling through resources or predicates, easy access to running processes through kubectl, and other cool features. Deis is a Heroku-like platform that intends to provide simple PaaS on top of other clustering systems. They currently support deployment through Fleet and have plans to support deployment on Kubernetes in the future. Plenty more to choose from with what seems like a new one every day. We as an industry are still exploring the space, and it’s exciting to see what people continue to come up with.
  28. We’re hopefully all using continuous integration systems in our infrastructures, but how are you managing your build and testing environment? Install your tools on your local box? How do you update? Try a Docker image for your build and test environments. Easily update your environment by updating your image and push to your repository. Try different build configurations without a complex setup. Support multiple versions of languages Try building with newer versions of dependencies Throw it away when you’re finished.
  29. An additional suggestion for people using containers for testing and deployment. It’s tempting to try to save time by shipping your container with production code with testing dependencies and build environment. This can potentially add a lot of unnecessary heft to your production artifact. A Go project I work on was able to go from a roughly 800 MB build image to a 39 MB image by statically compiling binaries, removing the build chain, and including only dependencies required for production use. Reducing that resulted in much faster container start times and faster start times. Something to consider when planning your Dockerized deployment pipeline is what you’ll be including in the final Docker image. It’s tempting to deploy your continuous integration image since it has everything you might need, but you might have some additional things you don’t need like testing dependencies and unnecessary environment items that could take up unnecessary space. A Golang project I worked on has a CI image that is roughly 800MB. This image includes the full Golang 1.4 build tools, additional testing scripts, and is based on Ubuntu to make it easier for other developers to play around if desired. Our Golang binary when statically compiled needed only a few compiled tools and timezone data. We based this image on Alpine Linux and included only these few items and found ourselves with only a 30MB image to send to production. You might not have such profound savings with other languages, but a little creativity might yield some good savings!
  30. The kube-register project provides a one-liner in their README page to compile a Go binary in a containerized build environment. Docker project has an official development environment that can be setup with the Dockerfile in the root of their repository. Consider sending a pull request to containerize an open source application for easy hacking for beginners!