SlideShare a Scribd company logo
1 of 37
PHPBenelux Wednesday, October 22, 2014
** VVaaggrraanntt iiss aa MMaannaaggeerr ffoorr VVMMss 
** VVaaggrraanntt iiss AAWWEESSOOMMEE!! 
** VVaaggrraanntt SSiimmpplliiffiieedd oouurr lliivveess ttrreemmeennddoouussllyy
● ** sseerrvveerr vviirrttuuaalliizzaattiioonn iiss ssllooww 
● ** hhaarrdd ttoo ddiissttrriibbuuttee ((ccoommppaarreedd ttoo ddoocckkeerr)) 
● ** bbaassee bbooxx ++ vvaaggrraanntt pprroovviissiioonn ((ppuuppppeett,, aannssiibbllee,, 
ssaallttssttaacckk)) 
● ** vvaaggrraanntt ppaacckkaaggee ----bbaassee [[hhaasshh]] ----oouuttppuutt 
[[bbooxxnnaammee..bbooxx]] 
● ** ffiixxeedd mmeemmoorryy ccoonnssuummppttiioonn
● ** ddiisskk ssppaaccee hhoogg 
● ** sseerrvviiccee iinnssttaallll // rreemmoovvee ttrriiaallss aarree 
eexxppeennssiivvee 
● ** ddeessttrrooyy ++ uupp iiss ccooffffeeee ttiimmee 
● ** hhyyppeerrvviissoorr aabbssttrraaccttss aann eennttiirree ddeevviiccee 
● ** eexxppeennssiivvee eemmuullaattiinngg vviirrttuuaall hhaarrddwwaarree
IItt aaiinn''tt aallll bbaadd!! 
** EExxcceelllleenntt ffoorr mmaannuuaall tteessttiinngg 
** EExxcceelllleenntt ffoorr SSeelleenniiuumm GGrriidd 
** EExxcceelllleenntt ffoorr ttaakkiinngg aann OOSS tteesstt ddrriivvee 
** EExxcceelllleenntt ffoorr rruunnnniinngg nnoonn lliinnuuxx aappppss 
** AAnndd pprroobbaabbllyy aa lloott mmoorree!! 
BBuutt iitt aaiinn''tt ggoooodd ffoorr ......
RRuunnnniinngg oorr 
ddeevveellooppiinngg 
aa LLiinnuuxx 
aapppplliiccaattiioonn
PPuurrrriinngg pp oowweerr!!!!!!
"Docker iiss aann ooppeenn ppllaattffoorrmm ffoorr ddeevveellooppeerrss 
aanndd ssyyssaaddmmiinnss ttoo bbuuiilldd,, sshhiipp,, aanndd rruunn 
ddiissttrriibbuutteedd aapppplliiccaattiioonnss..""
* dedicated tool to help build ssttaabbllee aapppplliiccaattiioonn 
eennvviirroonnmmeennttss 
** ddiissttrriibbuuttee tthhoossee eennvviirroonnmmeennttss eeaassiillyy 
** llooww ccoosstt iinnssttaallll // rreemmoovvee sseerrvviicceess
> whoami_ 
* built on top of LLXXCC ((ccoonnttaaiinneerr tteecchhnnoollooggyy)).. 
** uusseess ffiillee ssyysstteemm,, ssttoorraaggee,, CCPPUU,, RRAAMM,, aanndd ssoo oonn 
** jjuusstt aabbssttrraacctt tthhee ooppeerraattiinngg ssyysstteemm kkeerrnneell
> ls effect_ 
** mmoorree eeffffiicciieenntt iinn rreessoouurrccee tteerrmmss 
** lleeaavvee bbeehhiinndd 9999..99%% VVMM jjuunnkk 
** 44-66 ttiimmeess mmoorree sseerrvveerr aapppplliiccaattiioonn iinnssttaanncceess
Terminology 
* Image 
* Container 
* Repository 
* Registry
We don't need no stinking
We Need a Dockerfile 
nickbelhomme/apache nickbelhomme/foo 
FROM debian:wheezy 
MAINTAINER Nick Belhomme, 
contact@nickbelhomme.com 
RUN apt-get update 
RUN apt-get install -y apache2 wget 
vim curl 
# expose the ports 
EXPOSE 80 
FROM nickbelhomme/apache 
RUN a2enmod rewrite 
RUN apt-get install -y php5-common 
libapache2-mod-php5 php5-cli php5- 
intl php5-curl php5-pgsql 
ADD dev/apache/application.conf 
/etc/apache2/sites-available/ 
application.conf 
RUN a2ensite application.conf
Actually we Need multiple Dockerfiles 
1 FOR APACHE (+ PHP) 
1 FOR a DB 
1 PER Application 
1 FOR NODE 
1 FOR VARNISH 
1 FOR MEMCACHED 
1 FOR REDIS 
1 FOR ... 
Or use the Registry for pre-build images
Forge together 
Using 
Containers 
docker run -d -P --name postgres nickbelhomme/postgres 
docker run -d --link postgres:postgres --name applicationFoo -v 
/home/nick/vhosts/foo/application:/var/www/vhosts/local.foo.com -p 49101:80 
nickbelhomme/foo /usr/sbin/apachectl -D FOREGROUND
> docker ps 
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 
e39 node:latest "grunt watch" 5 days ago Up 2 seconds applicationFoo-grunt 
a2d applicationFoo:latest "apachectl 2 weeks ago Up 2 seconds 49101->80/tcp applicationFoo 
bda postgres:latest "/usr/lib/postgresql 4 weeks ago Up 3 seconds 49155->5432/tcp 
fooBar/postgres,applicationFoo/postgres,gooBar/postgres,postgres 
http://local.foo.com:49101 
/etc/hosts => Docker0-ip local.foo.com
> docker run --rm --link postgres:postgres nickbelhomme/postgres env 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
HOSTNAME=0bda3edb485e 
POSTGRES_PORT=tcp://10.66.33.13:5432 
POSTGRES_PORT_5432_TCP=tcp://10.66.33.13:5432 
POSTGRES_PORT_5432_TCP_ADDR=10.66.33.13 
POSTGRES_PORT_5432_TCP_PORT=5432 
POSTGRES_PORT_5432_TCP_PROTO=tcp 
POSTGRES_NAME=/loving_colden/postgres 
HOME=/var/lib/postgresql 
<?php host=' . getenv('POSTGRES_PORT_5432_TCP_ADDR') ?>
> docker logs –follow applicationFoo-grunt 
Done, without errors. 
Completed in 0.438s at Wed Oct 15 2014 19:06:28 GMT+0000 (UTC) - Waiting... 
OK 
>> File "rawJs/foo/form.js" changed. 
Running "concat:js" (concat) task 
File "./public/js/source.js" created. 
Done, without errors. 
Completed in 0.458s at Wed Oct 15 2014 19:11:34 GMT+0000 (UTC) - Waiting... 
Running "watch" task
> docker start postgres applicationFoo applicationFoo-grunt 
> docker stop postgres applicationFoo applicationFoo-grunt 
#!/bin/bash 
if [ "$1" = "start" ]; then 
docker start postgres applicationFoo applicationFoo-grunt 
exit 
fi 
if [ "$1" = "db" ]; then 
docker run --rm --link postgres:postgres nickbelhomme/postgres env 
exit 
fi 
if [ "$1" = "grunt" ]; then 
docker logs --follow applicationFoo-grunt 
exit 
fi 
> ./project start 
> ./project stop 
> ./project grunt 
> ./project ...
Team distribution
> docker login 
> docker push nickbelhomme/postgres 
> docker pull nickbelhomme/postgres 
> docker run [options] [container] 
> develop
Now some bad 
ass Super hero 
Tips
> docker build -t nickbelhomme/foo . 
> docker build –no-cache=true 
> docker run --name applicationFoo 
> docker run –rm ... 
> docker run -w /var/www/vhosts/local.foo.com 
> docker run -i -t nickbelhomme/foo /bin/bash 
> docker run -v hostDir:containerDir
> docker rm $(docker ps -a -q) 
> docker rmi $(docker images -a -q) 
> docker rmi $(docker images -q --filter "dangling=true")
Change the default Docker network address 
> cat /etc/default/docker 
# Docker Upstart and SysVinit configuration file 
# Customize location of Docker binary (especially for development testing). 
#DOCKER="/usr/local/bin/docker" 
# Use DOCKER_OPTS to modify the daemon startup options. 
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" 
DOCKER_OPTS="—bip=10.66.33.10/24" 
# If you need Docker to use an HTTP proxy, it can also be specified here. 
#export http_proxy="http://127.0.0.1:3128/" 
# This is also a handy place to tweak where Docker's temporary files go. 
#export TMPDIR="/mnt/bigdrive/docker-tmp"
*Mounting volumes absolute FROM GUEST 
docker run -v /c/Users:containerPath 
* hosts file need to be set with 192.168.59.103
Lightweight Tiny Core Linux made for Docker containers. 
Runs completely from RAM, weighs ~27MB, boots in ~5s
Remember: 
Keep your docker 
Images single 
responsibility 
http://blog.nickbelhomme.com | https://joind.in/12295

More Related Content

What's hot

Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
Jason Grimes
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 

What's hot (20)

Dependency Management with Composer
Dependency Management with ComposerDependency Management with Composer
Dependency Management with Composer
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?Composer - Package Management for PHP. Silver Bullet?
Composer - Package Management for PHP. Silver Bullet?
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment
 
C++ for the Web
C++ for the WebC++ for the Web
C++ for the Web
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in php
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
Phing: Building with PHP
Phing: Building with PHPPhing: Building with PHP
Phing: Building with PHP
 
Building and deploying PHP applications with Phing
Building and deploying PHP applications with PhingBuilding and deploying PHP applications with Phing
Building and deploying PHP applications with Phing
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Automated Deployment With Phing
Automated Deployment With PhingAutomated Deployment With Phing
Automated Deployment With Phing
 
Phing
PhingPhing
Phing
 
Ant vs Phing
Ant vs PhingAnt vs Phing
Ant vs Phing
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 

Similar to Vagrant move over, here is Docker

2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
tutorialsruby
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
tutorialsruby
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
tutorialsruby
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
tutorialsruby
 

Similar to Vagrant move over, here is Docker (20)

PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Docker practice
Docker practiceDocker practice
Docker practice
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Installing odoo v8 from github
Installing odoo v8 from githubInstalling odoo v8 from github
Installing odoo v8 from github
 
Happy porting x86 application to android
Happy porting x86 application to androidHappy porting x86 application to android
Happy porting x86 application to android
 
Beyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with PuppetBeyond Golden Containers: Complementing Docker with Puppet
Beyond Golden Containers: Complementing Docker with Puppet
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014Dockerizing Symfony Applications - Symfony Live Berlin 2014
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의OSS AWS 핸즈온 강의
OSS AWS 핸즈온 강의
 
Docker command
Docker commandDocker command
Docker command
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
mapserver_install_linux
mapserver_install_linuxmapserver_install_linux
mapserver_install_linux
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Vagrant move over, here is Docker

  • 1.
  • 3.
  • 4. ** VVaaggrraanntt iiss aa MMaannaaggeerr ffoorr VVMMss ** VVaaggrraanntt iiss AAWWEESSOOMMEE!! ** VVaaggrraanntt SSiimmpplliiffiieedd oouurr lliivveess ttrreemmeennddoouussllyy
  • 5.
  • 6. ● ** sseerrvveerr vviirrttuuaalliizzaattiioonn iiss ssllooww ● ** hhaarrdd ttoo ddiissttrriibbuuttee ((ccoommppaarreedd ttoo ddoocckkeerr)) ● ** bbaassee bbooxx ++ vvaaggrraanntt pprroovviissiioonn ((ppuuppppeett,, aannssiibbllee,, ssaallttssttaacckk)) ● ** vvaaggrraanntt ppaacckkaaggee ----bbaassee [[hhaasshh]] ----oouuttppuutt [[bbooxxnnaammee..bbooxx]] ● ** ffiixxeedd mmeemmoorryy ccoonnssuummppttiioonn
  • 7. ● ** ddiisskk ssppaaccee hhoogg ● ** sseerrvviiccee iinnssttaallll // rreemmoovvee ttrriiaallss aarree eexxppeennssiivvee ● ** ddeessttrrooyy ++ uupp iiss ccooffffeeee ttiimmee ● ** hhyyppeerrvviissoorr aabbssttrraaccttss aann eennttiirree ddeevviiccee ● ** eexxppeennssiivvee eemmuullaattiinngg vviirrttuuaall hhaarrddwwaarree
  • 8. IItt aaiinn''tt aallll bbaadd!! ** EExxcceelllleenntt ffoorr mmaannuuaall tteessttiinngg ** EExxcceelllleenntt ffoorr SSeelleenniiuumm GGrriidd ** EExxcceelllleenntt ffoorr ttaakkiinngg aann OOSS tteesstt ddrriivvee ** EExxcceelllleenntt ffoorr rruunnnniinngg nnoonn lliinnuuxx aappppss ** AAnndd pprroobbaabbllyy aa lloott mmoorree!! BBuutt iitt aaiinn''tt ggoooodd ffoorr ......
  • 9. RRuunnnniinngg oorr ddeevveellooppiinngg aa LLiinnuuxx aapppplliiccaattiioonn
  • 11. "Docker iiss aann ooppeenn ppllaattffoorrmm ffoorr ddeevveellooppeerrss aanndd ssyyssaaddmmiinnss ttoo bbuuiilldd,, sshhiipp,, aanndd rruunn ddiissttrriibbuutteedd aapppplliiccaattiioonnss..""
  • 12. * dedicated tool to help build ssttaabbllee aapppplliiccaattiioonn eennvviirroonnmmeennttss ** ddiissttrriibbuuttee tthhoossee eennvviirroonnmmeennttss eeaassiillyy ** llooww ccoosstt iinnssttaallll // rreemmoovvee sseerrvviicceess
  • 13. > whoami_ * built on top of LLXXCC ((ccoonnttaaiinneerr tteecchhnnoollooggyy)).. ** uusseess ffiillee ssyysstteemm,, ssttoorraaggee,, CCPPUU,, RRAAMM,, aanndd ssoo oonn ** jjuusstt aabbssttrraacctt tthhee ooppeerraattiinngg ssyysstteemm kkeerrnneell
  • 14. > ls effect_ ** mmoorree eeffffiicciieenntt iinn rreessoouurrccee tteerrmmss ** lleeaavvee bbeehhiinndd 9999..99%% VVMM jjuunnkk ** 44-66 ttiimmeess mmoorree sseerrvveerr aapppplliiccaattiioonn iinnssttaanncceess
  • 15. Terminology * Image * Container * Repository * Registry
  • 16.
  • 17.
  • 18. We don't need no stinking
  • 19. We Need a Dockerfile nickbelhomme/apache nickbelhomme/foo FROM debian:wheezy MAINTAINER Nick Belhomme, contact@nickbelhomme.com RUN apt-get update RUN apt-get install -y apache2 wget vim curl # expose the ports EXPOSE 80 FROM nickbelhomme/apache RUN a2enmod rewrite RUN apt-get install -y php5-common libapache2-mod-php5 php5-cli php5- intl php5-curl php5-pgsql ADD dev/apache/application.conf /etc/apache2/sites-available/ application.conf RUN a2ensite application.conf
  • 20.
  • 21. Actually we Need multiple Dockerfiles 1 FOR APACHE (+ PHP) 1 FOR a DB 1 PER Application 1 FOR NODE 1 FOR VARNISH 1 FOR MEMCACHED 1 FOR REDIS 1 FOR ... Or use the Registry for pre-build images
  • 22. Forge together Using Containers docker run -d -P --name postgres nickbelhomme/postgres docker run -d --link postgres:postgres --name applicationFoo -v /home/nick/vhosts/foo/application:/var/www/vhosts/local.foo.com -p 49101:80 nickbelhomme/foo /usr/sbin/apachectl -D FOREGROUND
  • 23. > docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e39 node:latest "grunt watch" 5 days ago Up 2 seconds applicationFoo-grunt a2d applicationFoo:latest "apachectl 2 weeks ago Up 2 seconds 49101->80/tcp applicationFoo bda postgres:latest "/usr/lib/postgresql 4 weeks ago Up 3 seconds 49155->5432/tcp fooBar/postgres,applicationFoo/postgres,gooBar/postgres,postgres http://local.foo.com:49101 /etc/hosts => Docker0-ip local.foo.com
  • 24. > docker run --rm --link postgres:postgres nickbelhomme/postgres env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=0bda3edb485e POSTGRES_PORT=tcp://10.66.33.13:5432 POSTGRES_PORT_5432_TCP=tcp://10.66.33.13:5432 POSTGRES_PORT_5432_TCP_ADDR=10.66.33.13 POSTGRES_PORT_5432_TCP_PORT=5432 POSTGRES_PORT_5432_TCP_PROTO=tcp POSTGRES_NAME=/loving_colden/postgres HOME=/var/lib/postgresql <?php host=' . getenv('POSTGRES_PORT_5432_TCP_ADDR') ?>
  • 25. > docker logs –follow applicationFoo-grunt Done, without errors. Completed in 0.438s at Wed Oct 15 2014 19:06:28 GMT+0000 (UTC) - Waiting... OK >> File "rawJs/foo/form.js" changed. Running "concat:js" (concat) task File "./public/js/source.js" created. Done, without errors. Completed in 0.458s at Wed Oct 15 2014 19:11:34 GMT+0000 (UTC) - Waiting... Running "watch" task
  • 26. > docker start postgres applicationFoo applicationFoo-grunt > docker stop postgres applicationFoo applicationFoo-grunt #!/bin/bash if [ "$1" = "start" ]; then docker start postgres applicationFoo applicationFoo-grunt exit fi if [ "$1" = "db" ]; then docker run --rm --link postgres:postgres nickbelhomme/postgres env exit fi if [ "$1" = "grunt" ]; then docker logs --follow applicationFoo-grunt exit fi > ./project start > ./project stop > ./project grunt > ./project ...
  • 28. > docker login > docker push nickbelhomme/postgres > docker pull nickbelhomme/postgres > docker run [options] [container] > develop
  • 29. Now some bad ass Super hero Tips
  • 30. > docker build -t nickbelhomme/foo . > docker build –no-cache=true > docker run --name applicationFoo > docker run –rm ... > docker run -w /var/www/vhosts/local.foo.com > docker run -i -t nickbelhomme/foo /bin/bash > docker run -v hostDir:containerDir
  • 31. > docker rm $(docker ps -a -q) > docker rmi $(docker images -a -q) > docker rmi $(docker images -q --filter "dangling=true")
  • 32. Change the default Docker network address > cat /etc/default/docker # Docker Upstart and SysVinit configuration file # Customize location of Docker binary (especially for development testing). #DOCKER="/usr/local/bin/docker" # Use DOCKER_OPTS to modify the daemon startup options. #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" DOCKER_OPTS="—bip=10.66.33.10/24" # If you need Docker to use an HTTP proxy, it can also be specified here. #export http_proxy="http://127.0.0.1:3128/" # This is also a handy place to tweak where Docker's temporary files go. #export TMPDIR="/mnt/bigdrive/docker-tmp"
  • 33.
  • 34.
  • 35. *Mounting volumes absolute FROM GUEST docker run -v /c/Users:containerPath * hosts file need to be set with 192.168.59.103
  • 36. Lightweight Tiny Core Linux made for Docker containers. Runs completely from RAM, weighs ~27MB, boots in ~5s
  • 37. Remember: Keep your docker Images single responsibility http://blog.nickbelhomme.com | https://joind.in/12295