Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Docker in Production - IPC 2016

1,684 views

Published on

You’ve heard about Docker, maybe you use it already as a development environment for virtualising your project on your local machine. But running your application or website with Docker in production is a whole different deal. In this session you’ll get a deeper insight into working with Docker in practice. Starting with the 101 of concepts we’ll go through a practical scenario for hosting, automatically deploying and monitoring an application in production with recommendations for a variety of tools and services.

Published in: Technology
  • Be the first to comment

Docker in Production - IPC 2016

  1. 1. Docker in Production
  2. 2. Robert Lemke CEO Flownative
 Project Founder Neos
 
 robert@flownative.com
 @robertlemke
  3. 3. Docker Toolbox www.docker.com/docker-toolbox
  4. 4. Docker Beta beta.docker.com
  5. 5. A quick
 Docker 101
  6. 6. Docker just for dev? What are the benefits?
  7. 7. Containers are
 Unix processes, not lightweight virtual machines.
  8. 8. One image per application and its dependencies.
  9. 9. site:
 image: tianon/true
 volumes:
 - /application
 
 application:
 image: eu.gcr.io/flownative-beach/beach-php-application- gateway:latest
 ports:
 - "8180:80"
 - "8122:22"
 volumes:
 - ./.Docker/secrets:/secrets
 - ./.Docker/configuration:/configuration
 volumes_from:
 - site
 environment:
 - BEACH_FLOW_BASE_CONTEXT=Development
 - BEACH_APPLICATION_USER_SERVICE_ENABLE=false

  10. 10. what's different in production?
  11. 11. monitoring deployment debugging security backup
 storage
  12. 12. the host
  13. 13. which operating system ?
  14. 14. provisioning
  15. 15. Docker Machine
  16. 16. resource "aws_instance" "www1" {
 ami = "${lookup(var.amis, var.region)}"
 availability_zone = "${var.region}a"
 instance_type = "t2.micro"
 subnet_id = "${aws_subnet.kubenet_craft.id}"
 associate_public_ip_address = true
 
 tags {
 Name = "www1.${var.regioncode}.flownative.net"
 }
 }
 
 resource "aws_route53_record" "kubemaster" {
 zone_id = "${var.flownativenet_zone_id}"
 name = "www1.${var.regioncode}"
 type = "A"
 ttl = "60"
 records = [
 "${aws_instance.www1.private_ip}"]
 }

  17. 17. images
  18. 18. use your own images
  19. 19. choose a base image security! size fitness
  20. 20. private repositories hub.docker.com
 quay.io
 Google Cloud
 AWS gitlab.com
  21. 21. sudo docker build -t beta.gcr.io/myproject/nginx:$BUILD_ID . sudo docker tag -f beta.gcr.io/myproject/nginx:$BUILD_ID beta.gcr.io/myproject/nginx sudo docker login -u _json_key -p "$(cat …json)" -e x@y.com https://beta.gcr.io sudo docker push beta.gcr.io/myproject/nginx:latest sudo docker push beta.gcr.io/myproject/nginx:$BUILD_ID
  22. 22. composition
  23. 23. Docker Compose
  24. 24. decouple … nginx:
 image: flownative/nginx:latest
 external_links:
 - cargo_jenkins_1
 ports:
 - "443:443"
 volumes:
 - data/certs/STAR_flownative_com.key:/etc/nginx/certs/flownative/docker-registry/STAR_flownative_com.key - data/certs/STAR_flownative_com-ssl-bundle.crt:/etc/nginx/certs/flownative/docker-registry/ STAR_flownative_com-ssl-bundle.crt
 volumes_from:
 - cargo_jenkins_1
 restart: always
 jenkins:
 build: "docker-jenkins"
 restart: always
 volumes:
 - data/jenkins:/var/jenkins_home
 - /var/run/docker.sock:/var/run/docker.sock
 - /usr/bin/docker:/usr/bin/docker
 ports:
 - "8080:8080"

  25. 25. deployment
  26. 26. #!/bin/bash
 
 ssh ubuntu@foo.flownative.net "cd ~/docker; sudo docker-compose -p cargo -f docker-compose-nginx.yml stop"
 ssh ubuntu@foo.flownative.net "cd ~/docker; sudo docker-compose -p cargo -f docker-compose-nginx.yml rm -f"
 
 scp ./docker-compose-nginx.yml ubuntu@cargo.flownative.net:/home/ubuntu/docker/
 
 ssh ubuntu@foo.flownative.net "cd ~/docker; sudo docker-compose -p cargo -f docker-compose-nginx.yml build"
 ssh ubuntu@foo.flownative.net "cd ~/docker; sudo docker-compose -p cargo -f docker-compose-nginx.yml up -d"

  27. 27. How would you design your infrastructure if you couldn’t login? Ever.
  28. 28. scheduling
  29. 29. Docker
 Cloud
  30. 30. Docker
 Cloud
  31. 31. apiVersion: v1
 kind: ReplicationController
 metadata:
 name: "neos-wwwneosio-elasticsearch-1"
 spec:
 replicas: 1
 
 selector:
 account: "neos"
 project: "wwwneosio"
 stage: "production"
 type: "elasticsearch"
 version: "1"
 
 template:
 metadata:
 
 labels:
 account: "neos"
 project: "wwwneosio"
 stage: "production"
 type: "elasticsearch"
 version: "1"
 
 spec:
 containers:
 
 - name: elasticsearch
 image: docker.flownative.com/flownative/elasticsearch:1
 ports:
 - containerPort: 9200
 resources:
 requests:
 memory: "100Mi"
 cpu: "10m"
 limits:
 memory: "800Mi"
 cpu: "500m"
 env:
 - name: ELASTICSEARCH_CLUSTER_NAME
 value: "neos-wwwneosio"

  32. 32. apiVersion: v1
 kind: Service
 metadata:
 name: elasticsearch-628f1e05
 labels:
 account: "neos"
 project: "wwwneosio"
 stage: "production"
 type: "elasticsearchmaster"
 spec:
 type: NodePort
 ports:
 - name: elasticsearchrestapi
 port: 9200
 targetPort: 9200
 - name: elasticsearchtransport
 port: 9300
 targetPort: 9300
 selector:
 account: "neos"
 project: "wwwneosio"
 stage: "production"
 type: "elasticsearchmaster"

  33. 33. service
 discovery
  34. 34. persistent data
  35. 35. host volume network filesystem cloud storages data-only containers
  36. 36. monitoring
  37. 37. Docker stats docker stats $(docker ps | awk '{if(NR>1) print $NF}')
  38. 38. tips&tricks
  39. 39. PaaS?
 your own?
  40. 40. what do you want to work on?
 
 Host maintenance?
  41. 41. Where to start?
  42. 42. develop images locally use Docker Compose (deploy with a script + Docker Compose) start using Docker Cloud / Giant Swarm look into Kubernetes on Google Cloud rehearse backup, monitoring, debugging 
 learn ~ Docker in Production
  43. 43. Containers will fundamentally change the way we ship web applications.
  44. 44. Containers will fundamentally change the way we develop web applications.
  45. 45. robert@flownative.com www.flownative.com @robertlemke share your thoughts

×