SlideShare a Scribd company logo
Running Docker in Production
Lauri Nevala, Founder
Stateful Services
© 2015 Kontena, Inc.
Containers Do Not Persist the Data!
© 2015 Kontena, Inc.
Apps with Persistent Data
•  Databases
•  File storages
•  Image registries
•  Version Control Systems
•  etc
© 2015 Kontena, Inc.
© 2015 Kontena, Inc.
How to solve the problem
•  Mounting a host directory as a data volume
•  Creating and mounting a data volume container
•  Using Docker volume drivers (>= 1.9)
© 2015 Kontena, Inc.
Mounting a host directory as a data
volume
•  $ docker run -d -P --name web -v /src/webapp:/opt/webapp
training/webapp python app.py
•  Cons:
•  Not recommended on production
•  Problems with file permissions
•  How to keep track what directories are in use?
© 2015 Kontena, Inc.
Creating and mounting a data volume
container
•  $ docker create -v /dbdata --name dbdata training/postgres /bin/
true
•  $ docker run -d --volumes-from dbdata --name db1 training/
postgres
© 2015 Kontena, Inc.
Using Docker volume drivers (>= 1.9)
•  $ docker volume create --name my_mongo_volume
•  $ docker run -d -v my_mongo_volume:/data –name mongo
mongo:3.0
© 2015 Kontena, Inc.
Stateful Services
How?
•  Creating services with persistent data with Kontena is easy
© 2015 Kontena, Inc.
# kontena.yml
mysql:
image: mariadb:5.5
stateful: true
$ kontena service create –stateful mongo mongo:3.0
Under the Hood
•  Kontena creates data volume container for stateful service
instances automatically
•  The running container will use volumes from the created data
volume container
•  The same data volume container is used for future containers
as well and the data won’t be lost
© 2015 Kontena, Inc.
Some Words of Caution
•  Stateful services can not be moved to another node
automatically
•  User have to migrate data manually
•  Data is not shared between service instances
•  Each stateful service instance will have an own data volume container
© 2015 Kontena, Inc.
Examples
MongoDB cluster – Pure Docker Way
•  https://medium.com/@gargar454/deploy-a-mongodb-cluster-in-
steps-9-using-docker-49205e231319#.urb900wm8
•  Step 1: Get the IP address of all three servers and export the
following IP addresses variables on all servers by running the
following commands on all servers (replace the IP addresses).
•  Ideally you would not have and the IPs can be resolved via DNS. Since
this is a test setup, this is easier.
© 2015 Kontena, Inc.
root@node*:/# export node1=10.11.32.174
root@node*:/# export node2=10.11.33.37
root@node*:/# export node3=10.11.31.176
•  Step 2: On node1, start the following mongodb container.
© 2015 Kontena, Inc.
root@node1:/# docker run --name mongo 
-v /home/core/mongo-files/data:/data/db 
--hostname="node1.example.com" 
-p 27017:27017 
-d mongo:2.6.5 –smallfiles
--replSet "rs0"
•  Step 3: Connect to the replica set and configure it. This is still
on node1. We will start another interactive shell into the mongo
container and start a mongo shell and initiate the replica set.
© 2015 Kontena, Inc.
root@node1:/# docker exec -it mongo /bin/bash
root@node1:/# mongo
MongoDB shell version: 2.6.5
> rs.initiate()
{
"info2" : "no configuration explicitly specified --
making one",
"me" : "node1.example.com:27017",
"info" : "Config now saved locally. Should come
online in about a minute.",
"ok" : 1
}
•  Step 4: Start Mongo on the other 2 nodes
© 2015 Kontena, Inc.
root@node2:/# docker run 
--name mongo 
-v /home/core/mongo-files/data:/data/db 
-v /home/core/mongo-files:/opt/keyfile 
--hostname="node2.example.com" 
--add-host node1.example.com:${node1} 
--add-host node2.example.com:${node2} 
--add-host node3.example.com:${node3} 
-p 27017:27017 -d mongo:2.6.5 
--smallfiles 
--replSet "rs0"
root@node3:/# docker run 
--name mongo 
-v /home/core/mongo-files/data:/data/db 
-v /home/core/mongo-files:/opt/keyfile 
--hostname="node3.example.com" 
--add-host node1.example.com:${node1} 
--add-host node2.example.com:${node2} 
--add-host node3.example.com:${node3} 
-p 27017:27017 -d mongo:2.6.5 
--smallfiles 
--replSet "rs0"
•  Step 5: Add the other 2 nodes into the replica set
•  Back to node1 where we are in the mongo shell. If you hit enter a few
times here, your prompt should have changed to “rs0:PRIMARY”. This
is because this is the primary node now for replica set “rs0".
© 2015 Kontena, Inc.
rs0:PRIMARY> rs.add("node2.example.com")
rs0:PRIMARY> rs.add("node3.example.com")
Let’s try it out
© 2015 Kontena, Inc.
MongoDB cluster – The Kontena Way
•  Step 1: Create / copy kontena.yml
•  https://github.com/kontena/examples/tree/master/mongodb-
cluster
© 2015 Kontena, Inc.
© 2015 Kontena, Inc.
peer:
image: mongo:3.0
stateful: true
command: --replSet kontena --smallfiles
instances: 3
hooks:
post_start:
- cmd: sleep 10
name: sleep
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.initiate());"
name: rs_initiate
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.add('%{project}-peer-2'))"
name: rs_add2
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.add('%{project}-peer-3'))"
name: rs_add3
instances: 1
oneshot: true
•  Step 2: Deploy the stack
© 2015 Kontena, Inc.
~/mongo-db-cluster$ kontena app deploy
MariaDB Galera Cluster
•  https://github.com/kontena/examples/tree/master/mariadb-
galera
•  Step 1: Write secrets to Kontena Vault
•  Step 2: Create / copy kontena.yml
© 2015 Kontena, Inc.
$ kontena vault write GALERA_XTRABACKUP_PASSWORD "top_secret"
$ kontena vault write GALERA_MYSQL_ROOT_PASSWORD "top_secret"
© 2015 Kontena, Inc.
seed:
image: jakolehm/galera-mariadb-10.0-xtrabackup:latest
stateful: true
command: seed
secrets:
- secret: GALERA_XTRABACKUP_PASSWORD
name: XTRABACKUP_PASSWORD
type: env
- secret: GALERA_MYSQL_ROOT_PASSWORD
name: MYSQL_ROOT_PASSWORD
type: env
node:
image: jakolehm/galera-mariadb-10.0-xtrabackup:latest
stateful: true
instances: 3
command: "node %{project}-seed.kontena.local,%{project}-node.kontena.local"
secrets:
- secret: GALERA_XTRABACKUP_PASSWORD
name: XTRABACKUP_PASSWORD
type: env
environment:
- KONTENA_LB_MODE=tcp
- KONTENA_LB_BALANCE=leastconn
- KONTENA_LB_INTERNAL_PORT=3306
- KONTENA_LB_EXTERNAL_PORT=3306
links:
- lb
lb:
image: kontena/lb:latest
instances: 2
© 2015 Kontena, Inc.
•  Step 3: Deploy the stack
•  Step 4: Remove seed node
$ kontena app deploy
$ kontena app scale seed 0
Thank You!www.kontena.io

More Related Content

What's hot

Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
NGINX, Inc.
 
Practical Design Patterns in Docker Networking
Practical Design Patterns in Docker NetworkingPractical Design Patterns in Docker Networking
Practical Design Patterns in Docker Networking
Docker, Inc.
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
Docker, Inc.
 
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep DiveDocker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker, Inc.
 
How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker
Jonathan Martin
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
rajdeep
 
Comprehensive Monitoring for Docker
Comprehensive Monitoring for DockerComprehensive Monitoring for Docker
Comprehensive Monitoring for Docker
Christian Beedgen
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
Docker, Inc.
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
Docker, Inc.
 
Docker SF Meetup January 2016
Docker SF Meetup January 2016Docker SF Meetup January 2016
Docker SF Meetup January 2016
Patrick Chanezon
 
Demystifying puppet
Demystifying puppetDemystifying puppet
Demystifying puppet
Ajeet Singh Raina
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
Ajeet Singh Raina
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
Erica Windisch
 
Docker serverless v1.0
Docker serverless v1.0Docker serverless v1.0
Docker serverless v1.0
Thomas Chacko
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
Ajeet Singh Raina
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
Ben Hall
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016
Chris Tankersley
 
Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019
Maura Teal
 
Taking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and DecideTaking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and Decide
Docker, Inc.
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
Web à Québec
 

What's hot (20)

Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
 
Practical Design Patterns in Docker Networking
Practical Design Patterns in Docker NetworkingPractical Design Patterns in Docker Networking
Practical Design Patterns in Docker Networking
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep DiveDocker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
 
How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker How we dockerized a startup? #meetup #docker
How we dockerized a startup? #meetup #docker
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 
Comprehensive Monitoring for Docker
Comprehensive Monitoring for DockerComprehensive Monitoring for Docker
Comprehensive Monitoring for Docker
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
 
Docker SF Meetup January 2016
Docker SF Meetup January 2016Docker SF Meetup January 2016
Docker SF Meetup January 2016
 
Demystifying puppet
Demystifying puppetDemystifying puppet
Demystifying puppet
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
 
Orchestrating Docker with OpenStack
Orchestrating Docker with OpenStackOrchestrating Docker with OpenStack
Orchestrating Docker with OpenStack
 
Docker serverless v1.0
Docker serverless v1.0Docker serverless v1.0
Docker serverless v1.0
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
 
From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016From Docker to Production - ZendCon 2016
From Docker to Production - ZendCon 2016
 
Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019Dev with Docker WCPHX 2019
Dev with Docker WCPHX 2019
 
Taking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and DecideTaking Docker to Production: What You Need to Know and Decide
Taking Docker to Production: What You Need to Know and Decide
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
 

Viewers also liked

Beginners Guide To Kontena
Beginners Guide To KontenaBeginners Guide To Kontena
Beginners Guide To Kontena
Kontena, Inc.
 
Vincent's Vinyl - ERD
Vincent's Vinyl - ERDVincent's Vinyl - ERD
Vincent's Vinyl - ERD
Bryan Reinbolt
 
WordPressCafe - Deploying WordPress using Kontena
WordPressCafe - Deploying WordPress using KontenaWordPressCafe - Deploying WordPress using Kontena
WordPressCafe - Deploying WordPress using Kontena
Kontena, Inc.
 
Barcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena IntroBarcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena Intro
Kontena, Inc.
 
The 12 Factor App
The 12 Factor AppThe 12 Factor App
The 12 Factor App
rudiyardley
 
Container Orchestration Wars (Micro Edition)
Container Orchestration Wars (Micro Edition)Container Orchestration Wars (Micro Edition)
Container Orchestration Wars (Micro Edition)
Karl Isenberg
 
Drone.io のご紹介
Drone.io のご紹介Drone.io のご紹介
Drone.io のご紹介
Uchio Kondo
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistence
Janakiram MSV
 
Achieving CI/CD with Kubernetes
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
Ramit Surana
 
Anatomy of a Continuous Integration and Delivery (CICD) Pipeline
Anatomy of a Continuous Integration and Delivery (CICD) PipelineAnatomy of a Continuous Integration and Delivery (CICD) Pipeline
Anatomy of a Continuous Integration and Delivery (CICD) Pipeline
Robert McDermott
 
Continuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaContinuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & Kontena
Jussi Nummelin
 

Viewers also liked (11)

Beginners Guide To Kontena
Beginners Guide To KontenaBeginners Guide To Kontena
Beginners Guide To Kontena
 
Vincent's Vinyl - ERD
Vincent's Vinyl - ERDVincent's Vinyl - ERD
Vincent's Vinyl - ERD
 
WordPressCafe - Deploying WordPress using Kontena
WordPressCafe - Deploying WordPress using KontenaWordPressCafe - Deploying WordPress using Kontena
WordPressCafe - Deploying WordPress using Kontena
 
Barcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena IntroBarcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena Intro
 
The 12 Factor App
The 12 Factor AppThe 12 Factor App
The 12 Factor App
 
Container Orchestration Wars (Micro Edition)
Container Orchestration Wars (Micro Edition)Container Orchestration Wars (Micro Edition)
Container Orchestration Wars (Micro Edition)
 
Drone.io のご紹介
Drone.io のご紹介Drone.io のご紹介
Drone.io のご紹介
 
Kubernetes dealing with storage and persistence
Kubernetes  dealing with storage and persistenceKubernetes  dealing with storage and persistence
Kubernetes dealing with storage and persistence
 
Achieving CI/CD with Kubernetes
Achieving CI/CD with KubernetesAchieving CI/CD with Kubernetes
Achieving CI/CD with Kubernetes
 
Anatomy of a Continuous Integration and Delivery (CICD) Pipeline
Anatomy of a Continuous Integration and Delivery (CICD) PipelineAnatomy of a Continuous Integration and Delivery (CICD) Pipeline
Anatomy of a Continuous Integration and Delivery (CICD) Pipeline
 
Continuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaContinuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & Kontena
 

Similar to Docker in Production - Stateful Services

Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM Connections
LetsConnect
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
Ben Hall
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
Docker, Inc.
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
Sreenivas Makam
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
Docker, Inc.
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administrators
Sharon James
 
How To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and ComposeHow To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and Compose
Docker, Inc.
 
GDG Lima - Docker Compose
GDG Lima - Docker ComposeGDG Lima - Docker Compose
GDG Lima - Docker Compose
Mario IC
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
Andrew Heifetz
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
dotCloud
 
WebSphere and Docker
WebSphere and DockerWebSphere and Docker
WebSphere and Docker
David Currie
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
Geeta Vinnakota
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support Engineer
Jeff Anderson
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Docker, Inc.
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
Bill Maxwell
 
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 20161049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
panagenda
 
Scaling Docker Containers using Kubernetes and Azure Container Service
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 Service
Ben Hall
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
Suresh Kumar
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
Ben Hall
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
Simon Storm
 

Similar to Docker in Production - Stateful Services (20)

Best And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM ConnectionsBest And Worst Practices Deploying IBM Connections
Best And Worst Practices Deploying IBM Connections
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
DCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker ContainersDCEU 18: Developing with Docker Containers
DCEU 18: Developing with Docker Containers
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
 
Sa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administratorsSa106 – practical solutions for connections administrators
Sa106 – practical solutions for connections administrators
 
How To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and ComposeHow To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and Compose
 
GDG Lima - Docker Compose
GDG Lima - Docker ComposeGDG Lima - Docker Compose
GDG Lima - Docker Compose
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
WebSphere and Docker
WebSphere and DockerWebSphere and Docker
WebSphere and Docker
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Troubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support EngineerTroubleshooting Tips from a Docker Support Engineer
Troubleshooting Tips from a Docker Support Engineer
 
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, DockerTroubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
Troubleshooting Tips from a Docker Support Engineer - Jeff Anderson, Docker
 
Austin - Container Days - Docker 101
Austin - Container Days - Docker 101Austin - Container Days - Docker 101
Austin - Container Days - Docker 101
 
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 20161049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
1049: Best and Worst Practices for Deploying IBM Connections - IBM Connect 2016
 
Scaling Docker Containers using Kubernetes and Azure Container Service
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 Service
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 

Recently uploaded

怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 

Recently uploaded (12)

怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 

Docker in Production - Stateful Services

  • 1. Running Docker in Production Lauri Nevala, Founder Stateful Services
  • 3. Containers Do Not Persist the Data! © 2015 Kontena, Inc.
  • 4. Apps with Persistent Data •  Databases •  File storages •  Image registries •  Version Control Systems •  etc © 2015 Kontena, Inc.
  • 6. How to solve the problem •  Mounting a host directory as a data volume •  Creating and mounting a data volume container •  Using Docker volume drivers (>= 1.9) © 2015 Kontena, Inc.
  • 7. Mounting a host directory as a data volume •  $ docker run -d -P --name web -v /src/webapp:/opt/webapp training/webapp python app.py •  Cons: •  Not recommended on production •  Problems with file permissions •  How to keep track what directories are in use? © 2015 Kontena, Inc.
  • 8. Creating and mounting a data volume container •  $ docker create -v /dbdata --name dbdata training/postgres /bin/ true •  $ docker run -d --volumes-from dbdata --name db1 training/ postgres © 2015 Kontena, Inc.
  • 9. Using Docker volume drivers (>= 1.9) •  $ docker volume create --name my_mongo_volume •  $ docker run -d -v my_mongo_volume:/data –name mongo mongo:3.0 © 2015 Kontena, Inc.
  • 11. How? •  Creating services with persistent data with Kontena is easy © 2015 Kontena, Inc. # kontena.yml mysql: image: mariadb:5.5 stateful: true $ kontena service create –stateful mongo mongo:3.0
  • 12. Under the Hood •  Kontena creates data volume container for stateful service instances automatically •  The running container will use volumes from the created data volume container •  The same data volume container is used for future containers as well and the data won’t be lost © 2015 Kontena, Inc.
  • 13. Some Words of Caution •  Stateful services can not be moved to another node automatically •  User have to migrate data manually •  Data is not shared between service instances •  Each stateful service instance will have an own data volume container © 2015 Kontena, Inc.
  • 15. MongoDB cluster – Pure Docker Way •  https://medium.com/@gargar454/deploy-a-mongodb-cluster-in- steps-9-using-docker-49205e231319#.urb900wm8 •  Step 1: Get the IP address of all three servers and export the following IP addresses variables on all servers by running the following commands on all servers (replace the IP addresses). •  Ideally you would not have and the IPs can be resolved via DNS. Since this is a test setup, this is easier. © 2015 Kontena, Inc. root@node*:/# export node1=10.11.32.174 root@node*:/# export node2=10.11.33.37 root@node*:/# export node3=10.11.31.176
  • 16. •  Step 2: On node1, start the following mongodb container. © 2015 Kontena, Inc. root@node1:/# docker run --name mongo -v /home/core/mongo-files/data:/data/db --hostname="node1.example.com" -p 27017:27017 -d mongo:2.6.5 –smallfiles --replSet "rs0"
  • 17. •  Step 3: Connect to the replica set and configure it. This is still on node1. We will start another interactive shell into the mongo container and start a mongo shell and initiate the replica set. © 2015 Kontena, Inc. root@node1:/# docker exec -it mongo /bin/bash root@node1:/# mongo MongoDB shell version: 2.6.5 > rs.initiate() { "info2" : "no configuration explicitly specified -- making one", "me" : "node1.example.com:27017", "info" : "Config now saved locally. Should come online in about a minute.", "ok" : 1 }
  • 18. •  Step 4: Start Mongo on the other 2 nodes © 2015 Kontena, Inc. root@node2:/# docker run --name mongo -v /home/core/mongo-files/data:/data/db -v /home/core/mongo-files:/opt/keyfile --hostname="node2.example.com" --add-host node1.example.com:${node1} --add-host node2.example.com:${node2} --add-host node3.example.com:${node3} -p 27017:27017 -d mongo:2.6.5 --smallfiles --replSet "rs0" root@node3:/# docker run --name mongo -v /home/core/mongo-files/data:/data/db -v /home/core/mongo-files:/opt/keyfile --hostname="node3.example.com" --add-host node1.example.com:${node1} --add-host node2.example.com:${node2} --add-host node3.example.com:${node3} -p 27017:27017 -d mongo:2.6.5 --smallfiles --replSet "rs0"
  • 19. •  Step 5: Add the other 2 nodes into the replica set •  Back to node1 where we are in the mongo shell. If you hit enter a few times here, your prompt should have changed to “rs0:PRIMARY”. This is because this is the primary node now for replica set “rs0". © 2015 Kontena, Inc. rs0:PRIMARY> rs.add("node2.example.com") rs0:PRIMARY> rs.add("node3.example.com")
  • 22. MongoDB cluster – The Kontena Way •  Step 1: Create / copy kontena.yml •  https://github.com/kontena/examples/tree/master/mongodb- cluster © 2015 Kontena, Inc.
  • 23. © 2015 Kontena, Inc. peer: image: mongo:3.0 stateful: true command: --replSet kontena --smallfiles instances: 3 hooks: post_start: - cmd: sleep 10 name: sleep instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.initiate());" name: rs_initiate instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.add('%{project}-peer-2'))" name: rs_add2 instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.add('%{project}-peer-3'))" name: rs_add3 instances: 1 oneshot: true
  • 24. •  Step 2: Deploy the stack © 2015 Kontena, Inc. ~/mongo-db-cluster$ kontena app deploy
  • 25. MariaDB Galera Cluster •  https://github.com/kontena/examples/tree/master/mariadb- galera •  Step 1: Write secrets to Kontena Vault •  Step 2: Create / copy kontena.yml © 2015 Kontena, Inc. $ kontena vault write GALERA_XTRABACKUP_PASSWORD "top_secret" $ kontena vault write GALERA_MYSQL_ROOT_PASSWORD "top_secret"
  • 26. © 2015 Kontena, Inc. seed: image: jakolehm/galera-mariadb-10.0-xtrabackup:latest stateful: true command: seed secrets: - secret: GALERA_XTRABACKUP_PASSWORD name: XTRABACKUP_PASSWORD type: env - secret: GALERA_MYSQL_ROOT_PASSWORD name: MYSQL_ROOT_PASSWORD type: env node: image: jakolehm/galera-mariadb-10.0-xtrabackup:latest stateful: true instances: 3 command: "node %{project}-seed.kontena.local,%{project}-node.kontena.local" secrets: - secret: GALERA_XTRABACKUP_PASSWORD name: XTRABACKUP_PASSWORD type: env environment: - KONTENA_LB_MODE=tcp - KONTENA_LB_BALANCE=leastconn - KONTENA_LB_INTERNAL_PORT=3306 - KONTENA_LB_EXTERNAL_PORT=3306 links: - lb lb: image: kontena/lb:latest instances: 2
  • 27. © 2015 Kontena, Inc. •  Step 3: Deploy the stack •  Step 4: Remove seed node $ kontena app deploy $ kontena app scale seed 0