SlideShare ist ein Scribd-Unternehmen logo
1 von 32
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.
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
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
Docker, Inc.
 

Was ist angesagt? (20)

Container Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in productionContainer Days Boston - Kubernetes in production
Container Days Boston - Kubernetes in production
 
Kubernetes Node Deep Dive
Kubernetes Node Deep DiveKubernetes Node Deep Dive
Kubernetes Node Deep Dive
 
Kubernetes intro public - kubernetes meetup 4-21-2015
Kubernetes intro   public - kubernetes meetup 4-21-2015Kubernetes intro   public - kubernetes meetup 4-21-2015
Kubernetes intro public - kubernetes meetup 4-21-2015
 
Microservices , Docker , CI/CD , Kubernetes Seminar - Sri Lanka
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
IPC16: A Practical Introduction to Kubernetes IPC16: A Practical Introduction to Kubernetes
IPC16: A Practical Introduction to Kubernetes
 
Kubernetes Hands-On Guide
Kubernetes Hands-On GuideKubernetes Hands-On Guide
Kubernetes Hands-On Guide
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2Kubernetes Architecture - beyond a black box - Part 2
Kubernetes Architecture - beyond a black box - Part 2
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
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
 
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
Thinking Inside the Container: A Continuous Delivery Story by Maxfield Stewart
 
Kubernetes 101 Workshop
Kubernetes 101 WorkshopKubernetes 101 Workshop
Kubernetes 101 Workshop
 
Package your Java EE Application using Docker and Kubernetes
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
 
Kubernetes architecture
Kubernetes architectureKubernetes architecture
Kubernetes architecture
 
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and BeyondTectonic Summit 2016: Kubernetes 1.5 and Beyond
Tectonic Summit 2016: Kubernetes 1.5 and Beyond
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech TalkKubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech Talk
 
Docker storage designing a platform for persistent data
Docker storage designing a platform for persistent dataDocker storage designing a platform for persistent data
Docker storage designing a platform for persistent data
 
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...
Online Meetup: Why should container system / platform builders care about con...
 
Deep dive in container service discovery
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discovery
 
Dockerizing Windows Server Applications by Ender Barillas and Taylor Brown
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
 
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...
Configuration Management and Transforming Legacy Applications in the Enterpri...
 

Ähnlich wie Docker for Fun and Profit

Ähnlich wie Docker for Fun and Profit (20)

Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)Docker for Deep Learning (Andrea Panizza)
Docker for Deep Learning (Andrea Panizza)
 
[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101[@NaukriEngineering] Docker 101
[@NaukriEngineering] Docker 101
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2Academy PRO: Docker. Part 2
Academy PRO: Docker. Part 2
 
Docker primer and tips
Docker primer and tipsDocker primer and tips
Docker primer and tips
 
Docker
DockerDocker
Docker
 
DOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDESDOCKER-PIAIC-SLIDES
DOCKER-PIAIC-SLIDES
 
Docker workshop GDSC_CSSC
Docker workshop GDSC_CSSCDocker workshop GDSC_CSSC
Docker workshop GDSC_CSSC
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Let's dockerize
Let's dockerizeLet's dockerize
Let's dockerize
 
Docker From Scratch
Docker From ScratchDocker From Scratch
Docker From Scratch
 
Introduction to Docker - Learning containerization XP conference 2016
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
Academy PRO: Docker. Lecture 2Academy PRO: Docker. Lecture 2
Academy PRO: Docker. Lecture 2
 
Docker for .net developer
Docker for .net developerDocker for .net developer
Docker for .net developer
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET Developers
 
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
 
Running the Oracle SOA Suite Environment in a Docker Container
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
 
Up and running with docker
Up and running with dockerUp and running with docker
Up and running with docker
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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.
  • 6.
  • 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
  • 17.
  • 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

Hinweis der Redaktion

  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!