Diego & Docker - Good friends
or not ?
• DevOps Engineer @anynines
• Used to work with Java (monoliths)
• Got to know Node.js and Microservices
• Learned about CloudFoundry
• Can I push my Container to CF ?
Why even use Docker ?
Code
Dockerfile
Docker Imagedocker build
Docker container
Code
docker run
Docker hub
Docker hub
Docker ImageDocker ImageDocker Image
Developer machine
Docker container
Code
node 0.12
Docker Image
Docker hub
Docker ImageDocker Image
new Developer machine test/staging/production
machine
Docker container
Code
Docker container
Code
node 6.3.0 node 5.0.0
node 5.0.0 node 5.0.0 node 5.0.0
Docker Image
Why even use Cloud Foundry
?
Developer machine
Code
Cloud Foundry
Instance
cf push
Developer machine
Code
Cloud Foundry
Instance
cf scale APP -i 4
Instance
Instance
Instance
Diego supports Docker
Docker Image
Filesystem
Commands
Garden Container
Filesystem
Droplet
Garden Linux
creates
Garden Container
Garden Linux
creates
Docker Image
Filesystem
Commands
Why even use Docker &
CloudFoundry
Importer
Docker Container
MongoDB
(Movies)
DBWrapper
Recommender
Docker Container
MongoDB
(Subscriber)
Spin it up
$ docker run -d -p 27017:27017 mongo
$ cd ../importer
$ PORT=… MOVIE_DB_HOST=… MOVIE_DB_PORT=… npm start
$ cd ../recommender
$ PORT=… MOVIE_DB_HOST=… MOVIE_DB_PORT=… npm start
$ cd db
$ PORT=… MOVIE_MONGO_URI=mongodb://192… npm start
$ docker pull mongo
Docker Container
Docker ContainerDocker Container
Importer
Docker Container
MongoDB
(Movies)
DBWrapper
Recommender
Docker Container
MongoDB
(Subscriber)
Spin it up with Docker
$ docker-compose up
Importer
Docker Container
MongoDB
(Movies)
DBWrapper
Recommender
Docker Container
MongoDB
(Subscriber)
$ MONGO_URI=… npm start
local
$ MOVIE_DB_HOST=… npm start $ MOVIE_DB_HOST=… npm start
MongoDB
(Movies)
DBWrapper
cloud
manifest.yml
Importer
DBWrapper
manifest.yml
cloud
DBWrapper
Recommender
cloud
manifest.yml
Recommender
MongoDB
(Subscriber)
manifest.yml
cloud
Deploy it on Cloud Foundry
$ docker build -t mebnoah/moviez_db .
$ docker push mebnoah/moviez_db
$ cf push --docker-image mebnoah/moviez_db
$ cd db
$ cd ../importer
$ docker build -t mebnoah/moviez_importer .
$ docker push mebnoah/moviez_importer
$ cf push --docker-image mebnoah/moviez_importer
$ cd ../recommender
$ docker build -t mebnoah/moviez_recommender .
$ docker push mebnoah/moviez_recommender
$ cf push --docker-image mebnoah/moviez_recommender
State of the onion
Spin it up with just 1 command
• Build each Docker image explicitly
• Register on Docker Hub and push each
image
• Push each app separately to CF
You decide wether to push a
micro service with or without
docker !
I would push it without docker
Spin it up with just 1 command
Push it to CF with just 1
command
Support Continuous
Integration/Deployment
There is a friendship but it’s not
a good one
Questions ?
• github.com/mebnoah
• twitter.com/mebnoah
Follow me

Docker & Diego - good friends or not? | anynines

Editor's Notes

  • #2 • I want to take you on a journey of me asking myself if docker and diego/CloudFoundry are good friends  • First of all let me tell you a little bit about me and why I want to take you on that journey
  • #4 * Lets answer some question first
  • #5 * 3 Advantages
  • #9 Works on my machine -> works on every other machine New Devs -> increase productivity, no complicated setup Other machines -> test machine, staging -> supports continuous integration/deployment Even on production -> remember 12Factors dev/prod parity ?! there you have it ! I will mention the other 2 Advantages later on
  • #12 Auto Healing Marketplace for backing services (PCF from scratch, OS CF + anynines)
  • #13 Why can we even use docker in diego ?
  • #14 Garden Linux supports mounting Docker images as root file system for container it constructs  Therefore Garden Linux uses the same libraries that power docker 
  • #15 * Warden Linux couldn't do that
  • #16 therefore I want to show you a litte micro service architecture I implemented at the beginning I wanted to play around with seneca
  • #17 importing movies from a movie database in my own db Register with email address to recommender -> sends recommendation (random movie) every day 1 Second advantage of docker: docker pull mongo
  • #18 * But i decided to dockerize the micro services because of the advantages I talked before (other dev can start easily, can deploy everywhere)
  • #21 env file
  • #22 third advantage of docker this was the state of my micro service landscape as I joined anynines I wanted to deploy the landscape on Cloud Foundry -> Changes regarding 12Factor (basically get stuff out of VCAP_SERVICES Env variables)
  • #23 Switch for local & cloud profile Nothing changes for running it with docker, because development profile is default 2. Kästchen
  • #25 For production you would probably use a service discovery/registry like consul/eureka
  • #27 Why do I need docker anymore ? Lets try to deploy to deploy it and see what i get
  • #28 * Note: only images from accessible docker registry are supported as far as I know, so u have to register and upload your image
  • #29 man muss build pack weglassen
  • #31 dont have to deploy it to CF or start every service separately in order to test new changes -> local development/testing -> new Devs -> it will run
  • #32 because there are 3 Micros -> thats not really awesome
  • #39 * Both Technologies support it
  • #40 It can be improved if mainfest files support docker-images, but still I can’t think of any advantage of deploying docker images