Dockerize and Ship it

Intro to Docker
What is Docker?
Docker is an open source platform for building, deploying, and managing containerized applications.
Containers simplify the delivery of distributed applications and have become increasingly popular as organizations shift to cloud-native development and hybrid multicloud environments.
Docker vs Virtual Machines

Docker vs Virtual Machines
Benefits of apps inside containers
- Less startup time.
- Better resource distribution.
- Direct access to the hardware.
History
Docker was created by Salomon Hykes as an internal project in dotCloud presented in 2013 at the PyCon.
The Docker runtime was written in Go, nowadays the biggest contributors to this project have been Google, Microsoft, IBM, Huawei, Red Hat y el Docker Team.
Benefits of using Docker
- Fast (deployment, migration, restart).
- Lightweight (Disk & CPU)
- Open Source.
- Portable apps.
- Microservices and integrations (APIs)
- DevOps Simplifications
- Version Control Software
Docker commons uses
- Sandbox environments (develop, test, debug).
- Continuo integrations and Deployment.
- Application scaling.
- Desarrollo colaborativo.
- Infrastructura configurations.
- Local development.
- Applications multi-tier.
- PaaS and SaaS.
Docker Architecture
Docker Image
Text

Docker Container

Dockerfile
Text file containing the commands used by the user to create an image.
FROM busybox
MAINTAINER Gustavo Gimenez <gimenezanderson@gmail.com>
RUN mkdir /app
ADD build/geo /app
RUN mkdir /app/data
RUN chmod -R 777 /app
EXPOSE 4000
CMD ["./app/geo"]
Docker commands
Most used docker commands
// Información general
man docker // man docker-run
docker help // docker help run
docker info
docker version
docker network ls
// Imagenes
docker images // docker [IMAGE_NAME]
docker pull [IMAGE] // docker push [IMAGE]
// Contenedores
docker run
docker ps // docker ps -a, docker ps -l
docker stop/start/restart [CONTAINER]
docker stats [CONTAINER]
docker top [CONTAINER]
docker port [CONTAINER]
docker inspect [CONTAINER]
docker inspect -f "{{ .State.StartedAt }}" [CONTAINER]
docker rm [CONTAINER]
Examples
SSH inside a container
docker pull ubuntu
docker run -it --name ubuntu_example ubuntu /bin/bash
Example
Build an Image
FROM busybox
MAINTAINER Gustavo Gimenez <gimenezanderson@gmail.com>
RUN mkdir /app
ADD build/server /app
RUN mkdir images
ADD images /images
RUN chmod -R 777 /app
EXPOSE 9000
ENTRYPOINT "/app/server"
Dockerfile
// Build image
docker build -t image-server .
// Run it
docker run -d -p 9000:9000 --name server-ex image-server
Commands
Example
Docker Volume
// Run it
docker run -d -p 8080:90 --name volume-server-example -v $(pwd):/usr/share/nginx/html nginx
Using a nginx server
Example
Test Docker Image
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
Dockerfile
docker run -it --name sinatra-test sinatra-app rspec spec/app_spec.rb
Run image
Example
Test Docker Image
FROM gusga/sinatra-app:0.1
CMD [ "sh", "-c", "rspec"]
Build image
docker run -it --name sinatra-test sinatra-app rspec spec/app_spec.rb
Run it
docker build -f Dockerfile.test -t sinatra-test-image .
Dockerfile.test
Example
Share Image
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
Build image
docker push gust/sinatra-app
Publish
docker build . -t gusga/sinatra-app
Dockerfile file
Docker runtime alternatives


Rkt
Linux Containers LCX
LXD container hypervisor
Docker Services
Tipo | Software |
---|---|
Clustering/orchestration | Swarm, Kubernetes, Marathon, MaestroNG, decking, shipyard |
Docker registries | Portus, Docker Distribution, hub.docker.com, quay.io, Google container registry, Artifactory, projectatomic.io |
PaaS with Docker | Rancher, Tsuru, dokku, flynn, Octohost, DEIS |
OS made of Containers | RancherOS |
Beyond Docker
Cloud Native Apps

Cloud Native Apps
Stack

Cloud Native Apps
Stack

Dockerize - SP500
By Gustavo Giménez
Dockerize - SP500
- 151