Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Docker
Narato DevOps Series
Agenda
 What is docker and why use it
 The basic docker tools
 Docker during development
 Docker during CI and testing
 Docker in production
 Q & A
Not on the agenda
 How do docker or linux containers actually work
What is Docker?
“Docker allows you to package an application with all of its dependencies into a standardized unit for
software development.”
What is Docker?
Docker is an opinioned implementation for building, shipping and deploying applications as
standalone containers.
What are docker containers?
Docker containers are a Linux technology!
What are docker containers?
Why?
Why would we want to use them?
Why?
Languages
.NET, NodeJS, Java,
Python. Go, …
Applications
Web Services,
Background Workers,
Databases, …
Libraries
.NET Framework,
ExpressJS, Django, Ruby
On Rails, …
Modern architectures have a diverse
ecosystem.
More sources to handle.
Why?
Development
Environment
Production
Environment
Test
Environment
IoT Devices
Cloud
Providers
Virtual
Machines
Shared
Hosting
CI
Environment
Linux
Windows OS X
QA
Environment
Bare Metal
More targets to handle.
Why?
Networking, security, orchestration, oh my
…
Virtual Machines vs Docker
The container perspective
Containers
Many products
Containers
Many transports
Linux Containers
Distro and vendor neutral environment for
the development of Linux container
technologies.
LXC, LXD, …
https://linuxcontainers.org/
Alternatives to Docker
 Linux Containers
https://linuxcontainers.org/
 Flockport
https://www.flockport.com/
 Rocket (CoreOS)
https://github.com/coreos/rkt
 Drawbridge (Microsoft)
http://research.microsoft.com/en-us/projects/drawbridge/
 LXD (Ubuntu/OpenStack)
http://www.ubuntu.com/cloud/lxd
 Windows Containers
https://msdn.microsoft.com/en-
us/virtualization/windowscontainers/quick_start/manage_docker?f=255&MSPPError=-2147217396
Even Microsoft joins in
 https://azure.microsoft.com/en-us/blog/new-windows-server-containers-and-azure-support-for-
docker/
 https://azure.microsoft.com/en-us/blog/containers-docker-windows-and-trends/
 https://msdn.microsoft.com/en-
us/virtualization/windowscontainers/quick_start/manage_docker?f=255&MSPPError=-2147217396
Docker Tools
Docker Products
docker-machine
Automate Docker provisioning.
docker-machine
docker-machine [command] [machine-name]
docker-machine start default
docker-machine status default
docker-machine env default
docker engine
Docker Engine runs on Linux to create the
operating environment for your
distributed applications.
docker engine
docker [options] command [arg...]
docker images
docker ps
docker build .
docker run –p “8888:8888” image_name
docker-compose
Docker Compose allows you to define
your multi-container application with all of
its dependencies in a single file, then spin
your application up in a single command.
docker-compose
docker-compose [options] [command] [args]
docker-compose up
docker-compose start
docker-compose stop
docker-compose build
docker-compose ps
docker-compose scale service=2
swarm
Docker Swarm provides native clustering
capabilities to turn a group of Docker
engines into a single, virtual Docker
Engine.
swarm
Can run as a container on a docker engine
instance.
docker run swarm
Using Docker in development
Docker in the development part of Application Lifecycle Management
Development
FROM node
MAINTAINER Stefan Alaerts <stefan.alaerts@narato.be>
RUN apt-get update -qq && apt-get install -y build-essential
RUN mkdir /eventhandler-api-service
COPY . /eventhandler-api-service/
WORKDIR /eventhandler-api-service
ENV NODE_ENV production
RUN npm install
EXPOSE 8888
CMD node lib/index.js
Use a Dockerfile to describe how docker
should build an image for your
application.
The resulting image should preferably be
self-contained.
Development
https://docs.docker.com/engine/userguide/eng-
image/dockerfile_best-practices/
Use the best practices when authoring
Dockerfiles.
Development
 docker build –t {tag} .
Build images using docker engine.
Development
version: '2'
services:
bus:
image: rabbitmq:3-management
ports:
- "15672:15672"
- "5672:5672"
hostname: eventhandler-bus
api:
build: ./src/api
ports:
- "8888:8888"
hostname: eventhandler-api
environment:
- CONFIGURATION_URL=eventhandler-configuration
- CONFIGURATION_PORT=4050
- BUS_URL=eventhandler-bus
command: nodemon -L lib/index.js
Use a docker-compose.yml file to describe
configuration for multiple containers.
Development
 docker-compose up
Use docker-compose to run all of your
containers as a single unit.
Tips for Windows users
Don’t suspend your computer while docker-machine is running a
machine in VirtualBox.
Doing so often breaks networking.
Tips for Windows users
When using volumes, make sure your project folder is inside your
user home directory. (VirtualBox shared folders limitation.)
Tips for Linux users
Use the power of the command line to remove all images with one
command:
docker rm `docker ps -aq`
Tips for all users
Use the docker-compose extends functionality.
You can auto-reload your application in development by sharing your
code using volumes while embedding the code in production.
Most production tools (Docker Cloud, Rancher, …) also support
extending compose configurations.
Tips for all users
You can access the shell of a running container if you need it.
docker exec –i –t [container_id|container_name] bash
Using Docker after development
Docker in the CI and testing part of Application Lifecycle Management
Extending development flow
Docker Machine (Windows, OSX)
Docker Engine
Docker Compose
Application Lifecycle Management
https://blog.docker.com/2015/09/docker-hub-2-0/
DevOps with Docker
http://thenewstack.io/how-docker-fits-into-the-devops-ecosystem/
DevOps with Docker
https://dzone.com/articles/docker-hub-20-integration-with-the-cloudbees-jenki
Tools for production
 Docker Cloud (previously Tutum)
 Rancher
 Deis
http://deis.io/
 Atomic
http://www.projectatomic.io/
Example: deploying a NodeJS blog
 docker login --username=salaerts --email=stefan.alaerts@gmail.com
 docker build –t salaerts/blog .
 docker push salaerts/blog
Example: deploying a NodeJS blog
 git push origin master
 Docker Hub kicks off an automated build on each push

More Related Content

Docker

Editor's Notes

  1. Solomon Hykes started Docker in France as an internal project within dotCloud, a platform-as-a-service company,[36] with initial contributions by other dotCloud engineers including Andrea Luzzardi and Francois-Xavier Bourlet. Jeff Lindsay also became involved as an independent collaborator. Docker represents an evolution of dotCloud's proprietary technology, which is itself built on earlier open-source projects such as Cloudlets. Docker was released as open source in March 2013.[13] On March 13, 2014, with the release of version 0.9, Docker dropped LXC as the default execution environment and replaced it with its own libcontainer library written in the Go programming language.[9][14] As of October 24, 2015[update], the project had over 25,600 GitHub stars (making it the 20th most-starred GitHub project), over 6,800 forks, and nearly 1,100 contributors.[37]
  2. Solomon Hykes started Docker in France as an internal project within dotCloud, a platform-as-a-service company,[36] with initial contributions by other dotCloud engineers including Andrea Luzzardi and Francois-Xavier Bourlet. Jeff Lindsay also became involved as an independent collaborator. Docker represents an evolution of dotCloud's proprietary technology, which is itself built on earlier open-source projects such as Cloudlets. Docker was released as open source in March 2013.[13] On March 13, 2014, with the release of version 0.9, Docker dropped LXC as the default execution environment and replaced it with its own libcontainer library written in the Go programming language.[9][14] As of October 24, 2015[update], the project had over 25,600 GitHub stars (making it the 20th most-starred GitHub project), over 6,800 forks, and nearly 1,100 contributors.[37]
  3. Difference with compose: swarm operates across multiple docker engine instances, compose scales services within a docker engine instance,