SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Converting Your Dev Environment
to a Docker Stack
Dana Luther
https://joind.in/talk/ab10a
https://github.com/DanaLuther/DevDockerStackSampleZCOE
Consolidated Work Stack
Friend A
PHP 5.6
Apache
MySQL
Cause B
PHP 7.1 FPM
NGINX
MySQL
PHP 7.0 FPM
NGINX
MySQL
Licensed
Application
Client D
PHP 7.1 FPM
NGINX
MySQL 5.3
Client C
PHP 5.6 FPM
NGINX
MySQL 5.2
PHP 5.6
Apache
MySQL 5.3
Client A
Client B
PHP 7.1
Apache
MySQL 5.4
THERE IS A
BETTER
WAY
VM
PHP 7.0 FPM
NGINX
MySQL
So, how does that work???
🤔
?
? ?
?
docker-compose.yml
Docker Compose Version
Services in the Stack
Configurations,
Secrets,
Storage Volumes,
etc.
Version: “3.4”
services:
nginx:
image: nginx
command: [
'sh',
'-c',
"exec nginx -g 'daemon off;'"
]
…
php:
image: php:7.2-fpm
…
network:
web_frontend
config:
nginx.conf:
file: ./nginx/nginx.conf
volumes:
…https://docs.docker.com/compose/compose-file/
SIDEBAR:The Docker Hierarchy
Image Container Service Stack
Node Swarm
> docker stack deploy …
Swarm
NODE 1
NODE 2
ETC.
PHP 1 MySQL
NGINX PHP 2
SIDEBAR:Docker Command Syntax
docker (object) (action) (args)
> docker container ls
> docker image ls
> docker service ls
> docker volume ls
image
container
stack
service
config
network
node
plugin
swarm
Objects
ls
ps
prune
inspect
create
remove / rm
Common
Actions
The swarm …
Node
Manager
Node
Worker
Node
Worker
Node
Worker
Node
Manager
A SWARM OF ONE
> docker swarm init
⚠ Common “Gotcha”
Swarm init — ONE TIME ONLY
* THE SWARM PERSISTS *
> docker swarm leave
> docker swarm leave —force
POPQUIZ! A. What’s the difference
between a container and a
service?
B. What’s the difference
between a service and a
stack?
Commonly Useful Images:
mysql
php
nginx
httpd
node
redis
wordpress
composer
memcached
alpine
postgres
busybox
phpmyadmin/phpmyadmin
https://store.docker.com
> docker image pull mysql:latest
BONUS POP QUIZ!
How do you pull an image manually?
Images for Automated Testing
selenium/standalone-chrome-debug
selenium/standalone-firefox-debug:2.53.0
acceptance.suite.yml
docker-compose.yml
SIDEBAR:Legacy images, containers, volumes
> docker image prune
> docker container prune
> docker (whatever) prune
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
SIDEBAR:LABELS — use them everywhere!
🤔
?
? ?
? The -f toggle
-f name=vm_php
-f label=com.envisage.desc=php
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
Volume Example for php
php:
volumes:
- ./public_html:/var/ www/html
Local path relative
to the file
Path location within
the container
Using named storage volumes
Volumes:
pub_html:
external: true
…
php:
volumes:
- pub_html:/var/ www/html
Volume name
Path location
within the container
> docker volume create pub_html /
—opt type=none /
—opt o=bind /
—opt device=/Volumes/E/site/
—label “com.envisage.desc=Site”
⚠ Common “Gotcha”
* BEWARE WINDOWS PATHS *
C:DockerDriveSite
/C/DockerDrives/Site
/host_mnt/c/DockerDrives/Site
//c/DockerDrives/Site
Windows
LCOW
Volume
Path
POPQUIZ! A. What is the command to
initialize a swarm?
B. What is the command to
deploy a docker stack?
> docker stack deploy -c docker-compose.yml vm
🤔
?
? ?
?
> docker service ls
> docker stack ps vm
> docker service logs vm_db
Want to see it in action?
> docker service logs vm_nginx -f
⚠ Common “Gotcha”
localhost:3306 db:3306
upstream fastcgi {
server 127.0.0.1:9000
}
upstream fastcgi {
server php:9000
}
Ok, great! But … 	 ¯_(ツ)_/¯
My production server
has lots of configurations
that have been customized…
php/conf.d/*
my.cnf
nginx.conf
nginx/conf.d/*
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
Config: mysite
> docker config inspect vm_mysite
version: “3.4”
services:
nginx:
image: nginx
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “Nginx Service”
volumes:
- ./public_html:/var/ www/html
configs:
- source: mysite
target: /etc/nginx/conf.d/mysite.conf
ports:
- “80:80”
- “443:443”
depends_on:
- php
- db
labels:
com.envisageinternational.desc: “Nginx Container”
command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”]
db:
image: mysql
ports:
- “3306:3306”
networks:
- web
secrets:
- db_pwd
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [ node.role == manager ]
environment:
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd
php:
image: php:7.0-fpm
networks:
- web
depends_on:
- db
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-FPM Service”
ports:
- “9000:9000”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-FPM Container”
php-cli:
image: php:7.0-cli
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.desc: “PHP-CLI Service”
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.desc: “PHP-CLI Container”
command: [‘bin/sh’, ‘-c’, “sleep infinity”]
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
db_pwd:
file: ./root_db_password.txt
PHP 7.0 FPM
NGINX
MySQL
Secret: db_pwd
> docker secret inspect zcoe_db_pwd
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker service update —config-rm vm_mysite 
—config-add source:mysite.2,target=/etc/nginx/default.conf 
vm_nginx
> docker config ls
Done with the project for now?
> docker stack rm vm
POPQUIZ! A. How do you check the
replication status of services?
B. How do you check for error
messages on the stack?
> docker stack ps vm —no-trunc
BONUS POINT
How do you avoid truncating the error message?
Same project … multiple production
targets?
docker-compose.yml
docker-compose-clientA.yml
docker-compose-clientB.yml
POPQUIZ! A. How do you filter a list of
docker objects (services,
containers, images, etc)
SIDEBAR:The $( ) magic with -q -l -f
-q Quiet (ID only)
-l Last Updated Only (1 result)
-f Filter (you remember this)
> docker container ls -q -l
> docker container exec -it $(docker ps -q -l -f name=vm_web) bash

Weitere ähnliche Inhalte

Was ist angesagt?

Writing & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgeWriting & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgePuppet
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorialtutorialsruby
 
Plongée dans l'écosystème Laravel
Plongée dans l'écosystème LaravelPlongée dans l'écosystème Laravel
Plongée dans l'écosystème LaravelGabriel Pillet 🐙
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLkangaro10a
 
Modern PHP Ch7 Provisioning Guide 導讀
Modern PHP Ch7 Provisioning Guide 導讀Modern PHP Ch7 Provisioning Guide 導讀
Modern PHP Ch7 Provisioning Guide 導讀Chen Cheng-Wei
 
Magento 2 Capistrano Deploy
Magento 2 Capistrano DeployMagento 2 Capistrano Deploy
Magento 2 Capistrano DeployDuke Dao
 
Developing MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack RoutersDeveloping MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack RoutersOnur Alanbel
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Thijs Feryn
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Codemotion
 
Troubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackTroubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackPuppet
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2Merixstudio
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notesPerrin Harkins
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPMax Romanovsky
 
Die .htaccess richtig nutzen
Die .htaccess richtig nutzenDie .htaccess richtig nutzen
Die .htaccess richtig nutzenWalter Ebert
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Arun Gupta
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hosterCombell NV
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIGert Vanthienen
 
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 betterZendCon
 
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyJim Jagielski
 

Was ist angesagt? (20)

Writing & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet ForgeWriting & Sharing Great Modules on the Puppet Forge
Writing & Sharing Great Modules on the Puppet Forge
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
Plongée dans l'écosystème Laravel
Plongée dans l'écosystème LaravelPlongée dans l'écosystème Laravel
Plongée dans l'écosystème Laravel
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
 
Modern PHP Ch7 Provisioning Guide 導讀
Modern PHP Ch7 Provisioning Guide 導讀Modern PHP Ch7 Provisioning Guide 導讀
Modern PHP Ch7 Provisioning Guide 導讀
 
Magento 2 Capistrano Deploy
Magento 2 Capistrano DeployMagento 2 Capistrano Deploy
Magento 2 Capistrano Deploy
 
Developing MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack RoutersDeveloping MIPS Exploits to Hack Routers
Developing MIPS Exploits to Hack Routers
 
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
 
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
 
Troubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise StackTroubleshooting the Puppet Enterprise Stack
Troubleshooting the Puppet Enterprise Stack
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
 
Die .htaccess richtig nutzen
Die .htaccess richtig nutzenDie .htaccess richtig nutzen
Die .htaccess richtig nutzen
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hoster
 
Php Power Tools
Php Power ToolsPhp Power Tools
Php Power Tools
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
 
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
 
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
 

Ähnlich wie Converting your DEV Environment to a Docker Stack - ZCOE18

Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaDana Luther
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Dana Luther
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelpurpleocean
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stackRootGate
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境謝 宗穎
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year laterChristian Ortner
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Laurent Domb
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationRadek Baczynski
 
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDropsolid
 
DevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps.com
 
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)Ben Hall
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Puppet
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
How to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysisHow to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysisTiago Simões
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressJeroen van Dijk
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudSalesforce Developers
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stackDana Luther
 
Automated Server Administration for DevSecOps
Automated Server Administration for DevSecOpsAutomated Server Administration for DevSecOps
Automated Server Administration for DevSecOpsAarno Aukia
 

Ähnlich wie Converting your DEV Environment to a Docker Stack - ZCOE18 (20)

Converting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - CascadiaConverting Your Dev Environment to a Docker Stack - Cascadia
Converting Your Dev Environment to a Docker Stack - Cascadia
 
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
 
Web scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannelWeb scale infrastructures with kubernetes and flannel
Web scale infrastructures with kubernetes and flannel
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...Automating Container Deployments on Virtualization with Ansible: OpenShift on...
Automating Container Deployments on Virtualization with Ansible: OpenShift on...
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimization
 
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google CloudDrupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
Drupaljam 2017 - Deploying Drupal 8 onto Hosted Kubernetes in Google Cloud
 
DevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to KnowDevOps and Hybrid Applications: What You Need to Know
DevOps and Hybrid Applications: What You Need to Know
 
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)
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
How to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysisHow to create a multi tenancy for an interactive data analysis
How to create a multi tenancy for an interactive data analysis
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
 
PHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the CloudPHP on Heroku: Deploying and Scaling Apps in the Cloud
PHP on Heroku: Deploying and Scaling Apps in the Cloud
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
 
Automated Server Administration for DevSecOps
Automated Server Administration for DevSecOpsAutomated Server Administration for DevSecOps
Automated Server Administration for DevSecOps
 

Mehr von Dana Luther

How to analyze your codebase with Exakat using Docker - Longhorn PHP
How to analyze your codebase with Exakat using Docker - Longhorn PHPHow to analyze your codebase with Exakat using Docker - Longhorn PHP
How to analyze your codebase with Exakat using Docker - Longhorn PHPDana Luther
 
Keep it Secret, Keep it Safe - Docker Secrets and DI
Keep it Secret, Keep it Safe - Docker Secrets and DIKeep it Secret, Keep it Safe - Docker Secrets and DI
Keep it Secret, Keep it Safe - Docker Secrets and DIDana Luther
 
Integrated Feature Management - Using Feature Flags - PHPSerbia
Integrated Feature Management - Using Feature Flags - PHPSerbiaIntegrated Feature Management - Using Feature Flags - PHPSerbia
Integrated Feature Management - Using Feature Flags - PHPSerbiaDana Luther
 
Integrated Feature Management - Using Feature Flags - MidwestPHP
Integrated Feature Management - Using Feature Flags - MidwestPHPIntegrated Feature Management - Using Feature Flags - MidwestPHP
Integrated Feature Management - Using Feature Flags - MidwestPHPDana Luther
 
Integrated Feature Management - Using Feature Flags - SunshinePHP
Integrated Feature Management - Using Feature Flags - SunshinePHPIntegrated Feature Management - Using Feature Flags - SunshinePHP
Integrated Feature Management - Using Feature Flags - SunshinePHPDana Luther
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPDana Luther
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsDana Luther
 

Mehr von Dana Luther (7)

How to analyze your codebase with Exakat using Docker - Longhorn PHP
How to analyze your codebase with Exakat using Docker - Longhorn PHPHow to analyze your codebase with Exakat using Docker - Longhorn PHP
How to analyze your codebase with Exakat using Docker - Longhorn PHP
 
Keep it Secret, Keep it Safe - Docker Secrets and DI
Keep it Secret, Keep it Safe - Docker Secrets and DIKeep it Secret, Keep it Safe - Docker Secrets and DI
Keep it Secret, Keep it Safe - Docker Secrets and DI
 
Integrated Feature Management - Using Feature Flags - PHPSerbia
Integrated Feature Management - Using Feature Flags - PHPSerbiaIntegrated Feature Management - Using Feature Flags - PHPSerbia
Integrated Feature Management - Using Feature Flags - PHPSerbia
 
Integrated Feature Management - Using Feature Flags - MidwestPHP
Integrated Feature Management - Using Feature Flags - MidwestPHPIntegrated Feature Management - Using Feature Flags - MidwestPHP
Integrated Feature Management - Using Feature Flags - MidwestPHP
 
Integrated Feature Management - Using Feature Flags - SunshinePHP
Integrated Feature Management - Using Feature Flags - SunshinePHPIntegrated Feature Management - Using Feature Flags - SunshinePHP
Integrated Feature Management - Using Feature Flags - SunshinePHP
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
 

Kürzlich hochgeladen

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxErYashwantJagtap
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 

Kürzlich hochgeladen (17)

Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Internet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptxInternet of Things Presentation (IoT).pptx
Internet of Things Presentation (IoT).pptx
 
Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 

Converting your DEV Environment to a Docker Stack - ZCOE18

  • 1. Converting Your Dev Environment to a Docker Stack Dana Luther https://joind.in/talk/ab10a https://github.com/DanaLuther/DevDockerStackSampleZCOE
  • 2. Consolidated Work Stack Friend A PHP 5.6 Apache MySQL Cause B PHP 7.1 FPM NGINX MySQL PHP 7.0 FPM NGINX MySQL
  • 3. Licensed Application Client D PHP 7.1 FPM NGINX MySQL 5.3 Client C PHP 5.6 FPM NGINX MySQL 5.2 PHP 5.6 Apache MySQL 5.3 Client A Client B PHP 7.1 Apache MySQL 5.4
  • 6. So, how does that work??? 🤔 ? ? ? ?
  • 7. docker-compose.yml Docker Compose Version Services in the Stack Configurations, Secrets, Storage Volumes, etc. Version: “3.4” services: nginx: image: nginx command: [ 'sh', '-c', "exec nginx -g 'daemon off;'" ] … php: image: php:7.2-fpm … network: web_frontend config: nginx.conf: file: ./nginx/nginx.conf volumes: …https://docs.docker.com/compose/compose-file/
  • 8. SIDEBAR:The Docker Hierarchy Image Container Service Stack Node Swarm
  • 9. > docker stack deploy … Swarm NODE 1 NODE 2 ETC. PHP 1 MySQL NGINX PHP 2
  • 10. SIDEBAR:Docker Command Syntax docker (object) (action) (args) > docker container ls > docker image ls > docker service ls > docker volume ls image container stack service config network node plugin swarm Objects ls ps prune inspect create remove / rm Common Actions
  • 12. Node Manager A SWARM OF ONE > docker swarm init
  • 13. ⚠ Common “Gotcha” Swarm init — ONE TIME ONLY * THE SWARM PERSISTS * > docker swarm leave > docker swarm leave —force
  • 14. POPQUIZ! A. What’s the difference between a container and a service? B. What’s the difference between a service and a stack?
  • 16. Images for Automated Testing selenium/standalone-chrome-debug selenium/standalone-firefox-debug:2.53.0 acceptance.suite.yml docker-compose.yml
  • 17. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune
  • 18. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 19. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 20. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 21. SIDEBAR:LABELS — use them everywhere! 🤔 ? ? ? ? The -f toggle -f name=vm_php -f label=com.envisage.desc=php
  • 22. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 23. Volume Example for php php: volumes: - ./public_html:/var/ www/html Local path relative to the file Path location within the container
  • 24. Using named storage volumes Volumes: pub_html: external: true … php: volumes: - pub_html:/var/ www/html Volume name Path location within the container > docker volume create pub_html / —opt type=none / —opt o=bind / —opt device=/Volumes/E/site/ —label “com.envisage.desc=Site”
  • 25. ⚠ Common “Gotcha” * BEWARE WINDOWS PATHS * C:DockerDriveSite /C/DockerDrives/Site /host_mnt/c/DockerDrives/Site //c/DockerDrives/Site Windows LCOW Volume Path
  • 26.
  • 27. POPQUIZ! A. What is the command to initialize a swarm? B. What is the command to deploy a docker stack?
  • 28. > docker stack deploy -c docker-compose.yml vm 🤔 ? ? ? ? > docker service ls > docker stack ps vm
  • 29. > docker service logs vm_db
  • 30.
  • 31. Want to see it in action? > docker service logs vm_nginx -f
  • 32. ⚠ Common “Gotcha” localhost:3306 db:3306 upstream fastcgi { server 127.0.0.1:9000 } upstream fastcgi { server php:9000 }
  • 33. Ok, great! But … ¯_(ツ)_/¯ My production server has lots of configurations that have been customized… php/conf.d/* my.cnf nginx.conf nginx/conf.d/*
  • 34. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 35. Config: mysite > docker config inspect vm_mysite
  • 36. version: “3.4” services: nginx: image: nginx networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “Nginx Service” volumes: - ./public_html:/var/ www/html configs: - source: mysite target: /etc/nginx/conf.d/mysite.conf ports: - “80:80” - “443:443” depends_on: - php - db labels: com.envisageinternational.desc: “Nginx Container” command: [‘sh’,'-c',"exec nginx -g 'daemon off;’”] db: image: mysql ports: - “3306:3306” networks: - web secrets: - db_pwd deploy: replicas: 1 restart_policy: condition: on-failure placement: constraints: [ node.role == manager ] environment: - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_pwd php: image: php:7.0-fpm networks: - web depends_on: - db deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-FPM Service” ports: - “9000:9000” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-FPM Container” php-cli: image: php:7.0-cli networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.desc: “PHP-CLI Service” volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.desc: “PHP-CLI Container” command: [‘bin/sh’, ‘-c’, “sleep infinity”] networks: web: configs: mysite: file: ./mysite.conf secrets: db_pwd: file: ./root_db_password.txt PHP 7.0 FPM NGINX MySQL
  • 37. Secret: db_pwd > docker secret inspect zcoe_db_pwd
  • 38. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker service update —config-rm vm_mysite —config-add source:mysite.2,target=/etc/nginx/default.conf vm_nginx > docker config ls
  • 39.
  • 40. Done with the project for now? > docker stack rm vm
  • 41. POPQUIZ! A. How do you check the replication status of services? B. How do you check for error messages on the stack? > docker stack ps vm —no-trunc BONUS POINT How do you avoid truncating the error message?
  • 42. Same project … multiple production targets? docker-compose.yml docker-compose-clientA.yml docker-compose-clientB.yml
  • 43. POPQUIZ! A. How do you filter a list of docker objects (services, containers, images, etc)
  • 44. SIDEBAR:The $( ) magic with -q -l -f -q Quiet (ID only) -l Last Updated Only (1 result) -f Filter (you remember this) > docker container ls -q -l > docker container exec -it $(docker ps -q -l -f name=vm_web) bash