SlideShare a Scribd company logo
Converting Your Dev Environment
to a Docker Stack
Dana Luther
https://joind.in/talk/4321c
https://git.io/JeB1S
@danaluther
Consolidated Work Stack
PHP 7.3 FPM
NGINX
MySQL
Consolidated Work Stack
Friend A
PHP 5.6
Apache
MySQL
PHP 7.3 FPM
NGINX
MySQL
Consolidated Work Stack
Friend A
PHP 5.6
Apache
MySQL
Cause B
PHP 7.1 FPM
NGINX
MySQL
PHP 7.3 FPM
NGINX
MySQL
Licensed
Application
Licensed
Application
PHP 5.6
Apache
MySQL 5.3
Client A
Licensed
Application
PHP 5.6
Apache
MySQL 5.3
Client A
Client B
PHP 7.1
Apache
MySQL 5.4
Licensed
Application
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
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
THERE IS A
BETTER
WAY
VM
PHP 7.0 FPM
NGINX
MySQL
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.7”
services:
nginx:
image: nginx
command: [
'sh',
'-c',
"exec nginx -g 'daemon off;'"
]
…
php:
image: php:7.3-fpm
…
network:
web_frontend
config:
nginx.conf:
file: ./nginx/nginx.conf
volumes:
…https://docs.docker.com/compose/compose-file/
SIDEBAR:The Docker Hierarchy
SIDEBAR:The Docker Hierarchy
Image Container Service Stack
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)
SIDEBAR:Docker Command Syntax
docker (object) (action) (args)
> docker container ls
SIDEBAR:Docker Command Syntax
docker (object) (action) (args)
> docker container ls
> docker image ls
SIDEBAR:Docker Command Syntax
docker (object) (action) (args)
> docker container ls
> docker image ls
> docker service ls
SIDEBAR:Docker Command Syntax
docker (object) (action) (args)
> docker container ls
> docker image ls
> docker service ls
> docker volume ls
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
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
Node
Manager
A SWARM OF ONE
> docker swarm init
⚠ Common “Gotcha”
Swarm init — ONE TIME ONLY
* THE SWARM PERSISTS *
⚠ Common “Gotcha”
Swarm init — ONE TIME ONLY
* THE SWARM PERSISTS *
> docker swarm leave
⚠ Common “Gotcha”
Swarm init — ONE TIME ONLY
* THE SWARM PERSISTS *
> docker swarm leave
> docker swarm leave —force
POPQUIZ!
POPQUIZ! A. What’s the difference
between a container and a
service?
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
https://store.docker.com
Commonly Useful Images:
mysql
php
nginx
httpd
node
redis
wordpress
composer
memcached
alpine
postgres
busybox
phpmyadmin/phpmyadmin
https://store.docker.com
Commonly Useful Images:
mysql
php
nginx
httpd
node
redis
wordpress
composer
memcached
alpine
postgres
busybox
phpmyadmin/phpmyadmin
https://store.docker.com
BONUS POP QUIZ!
Commonly Useful Images:
mysql
php
nginx
httpd
node
redis
wordpress
composer
memcached
alpine
postgres
busybox
phpmyadmin/phpmyadmin
https://store.docker.com
BONUS POP QUIZ!
How do you pull an image manually?
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
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
SIDEBAR:Legacy images, containers, volumes
> docker image prune
> docker container prune
> docker (whatever) prune
> docker system prune
SIDEBAR:Legacy images, containers, volumes
> docker image prune
> docker container prune
> docker (whatever) prune
> docker system prune
SIDEBAR:Legacy images, containers, volumes
> docker image prune
> docker container prune
> docker (whatever) prune
> docker system prune
SIDEBAR:Legacy images, containers, volumes
> docker image prune
> docker container prune
> docker (whatever) prune
> docker system prune
version: “3.7”
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.3-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.3-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.3 FPM
NGINX
MySQL
php:
image: php:7.3-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.3-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
version: “3.7”
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 7.0 FPM
NGINX
MySQL
php:
image: php:7.3-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.3-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
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;’”]
PHP 7.0 FPM
NGINX
MySQL
php:
image: php:7.3-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.3-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
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;’”]
PHP 7.0 FPM
NGINX
MySQL
SIDEBAR:LABELS — use them everywhere!
🤔
?
? ?
? The -f toggle
-f name=phpworld_php
-f label=com.envisage.desc=php
SIDEBAR:LABELS — use them everywhere!
🤔
?
? ?
? The -f toggle
-f name=phpworld_php
-f label=com.envisage.desc=php
SIDEBAR:LABELS — use them everywhere!
🤔
?
? ?
? The -f toggle
-f name=phpworld_php
-f label=com.envisage.desc=php
SIDEBAR:LABELS — use them everywhere!
🤔
?
? ?
? The -f toggle
-f name=phpworld_php
-f label=com.envisage.desc=php
version: “3.7”
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”
Using named storage volumes
> 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
Converting Your Dev Environment to a Docker Stack - php[world]
POPQUIZ!
POPQUIZ! A. What is the command to
initialize a swarm?
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 phpworld
> docker stack deploy -c docker-compose.yml phpworld
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack ps phpworld
> docker stack deploy -c docker-compose.yml phpworld
🤔
?
? ?
?
> docker service ls
> docker stack ps phpworld
> docker service logs phpworld_db
> docker service logs phpworld_db
> docker service logs phpworld_db
> docker service logs phpworld_db
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
Want to see it in action?
> docker service logs phpworld_nginx -f
Want to see it in action?
> docker service logs phpworld_nginx -f
⚠ Common “Gotcha”
localhost:3306 db:3306
⚠ 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.7”
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.3-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.3-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.7”
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
networks:
- web
deploy:
replicas: 1
restart_policy:
condition: on-failure
labels:
com.envisageinternational.d
volumes:
- ./public_html:/var/ www/html
labels:
com.envisageinternational.de
command: [‘bin/sh’, ‘-c’, “sleep
networks:
web:
configs:
mysite:
file: ./mysite.conf
secrets:
PHP 7.0 FPM
NGINX
MySQL
Config: mysite
Config: mysite
> docker config inspect phpworld_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.3-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.3-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
Secret: db_pwd
> docker secret inspect phpworld_db_pwd
⚠ Common “Gotcha”
> docker config ls
⚠ Common “Gotcha”
> docker config ls
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
> docker service update --config-rm phpworld_mysite 
--config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf 
phpworld_nginx
⚠ Common “Gotcha”
> docker config create mysite.2 ./mysite.conf
> docker config ls
> docker service update --config-rm phpworld_mysite 
--config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf 
phpworld_nginx
Converting Your Dev Environment to a Docker Stack - php[world]
> docker service rollback phpworld_nginx
> docker service rollback phpworld_nginx
Done with the project for now?
> docker stack rm phpworld
Done with the project for now?
> docker stack rm phpworld
Done with the project for now?
> docker stack rm phpworld
Done with the project for now?
> docker stack rm phpworld
POPQUIZ!
POPQUIZ! A. How do you check the
replication status of services?
POPQUIZ! A. How do you check the
replication status of services?
B. How do you check for error
messages on the stack?
POPQUIZ! A. How do you check the
replication status of services?
B. How do you check for error
messages on the stack?
BONUS POINT
POPQUIZ! A. How do you check the
replication status of services?
B. How do you check for error
messages on the stack?
BONUS POINT
How do you avoid truncating the error message?
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
Same project … multiple production
targets?
docker-compose.yml
docker-compose-clientA.yml
docker-compose-clientB.yml
Same project … multiple production
targets?
docker-compose.yml
docker-compose-clientA.yml
docker-compose-clientB.yml
Same project … multiple production
targets?
docker-compose.yml
docker-compose-clientA.yml
docker-compose-clientB.yml
POPQUIZ!
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)
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
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
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 -lq -f name=phpworld_nginx) bash
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 -lq -f name=phpworld_nginx) bash
Don’t love the command prompt?
🤔
?
? ??
Don’t love the command prompt?
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
POPQUIZ!
POPQUIZ!A. What is the command to
deploy a stack?
POPQUIZ!A. What is the command to
deploy a stack?
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]
SIDEBAR:Multi-stage builds
Converting Your Dev Environment to a Docker Stack - php[world]
> docker image build -f images/Dockerfile-bundled 
--target=phpworld_php 
-t dhluther/php:phpworld-demo .
> docker image build -f images/Dockerfile-bundled 
--target=phpworld_nginx 
-t dhluther/nginx:phpworld-demo .
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]
POPQUIZ!
POPQUIZ!A. Command line equivalent?
POPQUIZ!A. Command line equivalent?
> docker service ls -f name=phpworld
Converting Your Dev Environment to a Docker Stack - php[world]
Converting Your Dev Environment to a Docker Stack - php[world]
POPQUIZ!
POPQUIZ!A. Command line equivalent?
POPQUIZ!A. Command line equivalent?
> docker container ls
Converting Your Dev Environment to a Docker Stack - php[world]
> docker container exec -it 
$(docker ps -lq -f name=phpworld_php) 
bash
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]
> docker service update
--config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf 
phpworld_nginx
Command line equivalent?
Converting Your Dev Environment to a Docker Stack - php[world]
> docker node ls
Converting Your Dev Environment to a Docker Stack - php[world]
Questions??
https://joind.in/talk/4321c
🤔
?
? ?
?
@danaluther
https://www.linkedin.com/in/danaluther
dluther@envisageinternational.com
https://git.io/JeB1S
Converting Your Dev Environment to a Docker Stack - php[world]
Ad

More Related Content

What's hot (20)

Scaling Django
Scaling DjangoScaling Django
Scaling Django
Mike Malone
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Badge Poser v3.0 - A DevOps Journey
Badge Poser v3.0 - A DevOps JourneyBadge Poser v3.0 - A DevOps Journey
Badge Poser v3.0 - A DevOps Journey
Fabio Cicerchia
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
Joe Ferguson
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
Pablo Godel
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
Taming AEM deployments
Taming AEM deploymentsTaming AEM deployments
Taming AEM deployments
Jakub Wadolowski
 
Single page apps with drupal 7
Single page apps with drupal 7Single page apps with drupal 7
Single page apps with drupal 7
Chris Tankersley
 
今すぐ始めるCloud Foundry #hackt #hackt_k
今すぐ始めるCloud Foundry #hackt #hackt_k今すぐ始めるCloud Foundry #hackt #hackt_k
今すぐ始めるCloud Foundry #hackt #hackt_k
Toshiaki Maki
 
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
 
A Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web TrafficA Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web Traffic
Philip Tellis
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Pablo Godel
 
Configuring Django projects for multiple environments
Configuring Django projects for multiple environmentsConfiguring Django projects for multiple environments
Configuring Django projects for multiple environments
Apptension
 
Front-end tools
Front-end toolsFront-end tools
Front-end tools
Gleb Vinnikov
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
Jeff Jones
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matter
Tomas Doran
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
Tatsuhiko Miyagawa
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
Stein Inge Morisbak
 
Badge Poser v3.0 - A DevOps Journey
Badge Poser v3.0 - A DevOps JourneyBadge Poser v3.0 - A DevOps Journey
Badge Poser v3.0 - A DevOps Journey
Fabio Cicerchia
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
Joe Ferguson
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
Pablo Godel
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
Pablo Godel
 
Capistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient wayCapistrano deploy Magento project in an efficient way
Capistrano deploy Magento project in an efficient way
Sylvain Rayé
 
Site Performance - From Pinto to Ferrari
Site Performance - From Pinto to FerrariSite Performance - From Pinto to Ferrari
Site Performance - From Pinto to Ferrari
Joseph Scott
 
Single page apps with drupal 7
Single page apps with drupal 7Single page apps with drupal 7
Single page apps with drupal 7
Chris Tankersley
 
今すぐ始めるCloud Foundry #hackt #hackt_k
今すぐ始めるCloud Foundry #hackt #hackt_k今すぐ始めるCloud Foundry #hackt #hackt_k
今すぐ始めるCloud Foundry #hackt #hackt_k
Toshiaki Maki
 
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
 
A Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web TrafficA Node.JS bag of goodies for analyzing Web Traffic
A Node.JS bag of goodies for analyzing Web Traffic
Philip Tellis
 
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 -  Rock Solid Deployment of Symfony AppsSymfony Live NYC 2014 -  Rock Solid Deployment of Symfony Apps
Symfony Live NYC 2014 - Rock Solid Deployment of Symfony Apps
Pablo Godel
 
Configuring Django projects for multiple environments
Configuring Django projects for multiple environmentsConfiguring Django projects for multiple environments
Configuring Django projects for multiple environments
Apptension
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
Ben Hall
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
Jeff Jones
 
Web frameworks don't matter
Web frameworks don't matterWeb frameworks don't matter
Web frameworks don't matter
Tomas Doran
 

Similar to Converting Your Dev Environment to a Docker Stack - php[world] (20)

Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18
Dana Luther
 
Converting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker StackConverting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker Stack
Dana Luther
 
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
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Philip Zheng
 
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
RootGate
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
Sysdig
 
Automation day red hat ansible
   Automation day red hat ansible    Automation day red hat ansible
Automation day red hat ansible
Rodrigo Missiaggia
 
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
Salesforce Developers
 
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
Dropsolid
 
ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4
Jim Jagielski
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
Jeroen van Dijk
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
msyukor
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
Ken Robertson
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
謝 宗穎
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
Raul Leite
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
Омские ИТ-субботники
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
Software Guru
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
Nirmal Mehta
 
Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18Converting your DEV Environment to a Docker Stack - ZCOE18
Converting your DEV Environment to a Docker Stack - ZCOE18
Dana Luther
 
Converting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker StackConverting Your DEV Environment to a Docker Stack
Converting Your DEV Environment to a Docker Stack
Dana Luther
 
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
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Philip Zheng
 
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
RootGate
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.
 
Wordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccionWordpress y Docker, de desarrollo a produccion
Wordpress y Docker, de desarrollo a produccion
Sysdig
 
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
Salesforce Developers
 
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
Dropsolid
 
ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4ApacheCon 2014 - What's New in Apache httpd 2.4
ApacheCon 2014 - What's New in Apache httpd 2.4
Jim Jagielski
 
The Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/PressThe Enterprise Wor/d/thy/Press
The Enterprise Wor/d/thy/Press
Jeroen van Dijk
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
msyukor
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
謝 宗穎
 
Automação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOpsAutomação do físico ao NetSecDevOps
Automação do físico ao NetSecDevOps
Raul Leite
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
Омские ИТ-субботники
 
Instrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con GitlabInstrumentación de entrega continua con Gitlab
Instrumentación de entrega continua con Gitlab
Software Guru
 
Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112Nats meetup oct 2016 docker 112
Nats meetup oct 2016 docker 112
Nirmal Mehta
 
Ad

More from Dana Luther (7)

Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
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 PHP
Dana 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 DI
Dana 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 - PHPSerbia
Dana 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 - MidwestPHP
Dana 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 - SunshinePHP
Dana 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 Migrations
Dana Luther
 
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
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 PHP
Dana 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 DI
Dana 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 - PHPSerbia
Dana 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 - MidwestPHP
Dana 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 - SunshinePHP
Dana 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 Migrations
Dana Luther
 
Ad

Recently uploaded (19)

OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 
OSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description fOSI TCP IP Protocol Layers description f
OSI TCP IP Protocol Layers description f
cbr49917
 
Computers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers NetworksComputers Networks Computers Networks Computers Networks
Computers Networks Computers Networks Computers Networks
Tito208863
 
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...Mobile database for your company telemarketing or sms marketing campaigns. Fr...
Mobile database for your company telemarketing or sms marketing campaigns. Fr...
DataProvider1
 
DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)DNS Resolvers and Nameservers (in New Zealand)
DNS Resolvers and Nameservers (in New Zealand)
APNIC
 
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation TemplateSmart Mobile App Pitch Deck丨AI Travel App Presentation Template
Smart Mobile App Pitch Deck丨AI Travel App Presentation Template
yojeari421237
 
Best web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you businessBest web hosting Vancouver 2025 for you business
Best web hosting Vancouver 2025 for you business
steve198109
 
IT Services Workflow From Request to Resolution
IT Services Workflow From Request to ResolutionIT Services Workflow From Request to Resolution
IT Services Workflow From Request to Resolution
mzmziiskd
 
highend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptxhighend-srxseries-services-gateways-customer-presentation.pptx
highend-srxseries-services-gateways-customer-presentation.pptx
elhadjcheikhdiop
 
Understanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep WebUnderstanding the Tor Network and Exploring the Deep Web
Understanding the Tor Network and Exploring the Deep Web
nabilajabin35
 
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHostingTop Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
Top Vancouver Green Business Ideas for 2025 Powered by 4GoodHosting
steve198109
 
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry SweetserAPNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC Update, presented at NZNOG 2025 by Terry Sweetser
APNIC
 
White and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptxWhite and Red Clean Car Business Pitch Presentation.pptx
White and Red Clean Car Business Pitch Presentation.pptx
canumatown
 
(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security(Hosting PHising Sites) for Cryptography and network security
(Hosting PHising Sites) for Cryptography and network security
aluacharya169
 
Determining Glass is mechanical textile
Determining  Glass is mechanical textileDetermining  Glass is mechanical textile
Determining Glass is mechanical textile
Azizul Hakim
 
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 SupportReliable Vancouver Web Hosting with Local Servers & 24/7 Support
Reliable Vancouver Web Hosting with Local Servers & 24/7 Support
steve198109
 
Perguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolhaPerguntas dos animais - Slides ilustrados de múltipla escolha
Perguntas dos animais - Slides ilustrados de múltipla escolha
socaslev
 
project_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptxproject_based_laaaaaaaaaaearning,kelompok 10.pptx
project_based_laaaaaaaaaaearning,kelompok 10.pptx
redzuriel13
 
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC -Policy Development Process, presented at Local APIGA Taiwan 2025
APNIC
 
5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx5-Proses-proses Akuisisi Citra Digital.pptx
5-Proses-proses Akuisisi Citra Digital.pptx
andani26
 

Converting Your Dev Environment to a Docker Stack - php[world]

  • 1. Converting Your Dev Environment to a Docker Stack Dana Luther https://joind.in/talk/4321c https://git.io/JeB1S @danaluther
  • 2. Consolidated Work Stack PHP 7.3 FPM NGINX MySQL
  • 3. Consolidated Work Stack Friend A PHP 5.6 Apache MySQL PHP 7.3 FPM NGINX MySQL
  • 4. Consolidated Work Stack Friend A PHP 5.6 Apache MySQL Cause B PHP 7.1 FPM NGINX MySQL PHP 7.3 FPM NGINX MySQL
  • 7. Licensed Application PHP 5.6 Apache MySQL 5.3 Client A Client B PHP 7.1 Apache MySQL 5.4
  • 8. Licensed Application 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
  • 9. 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
  • 14. So, how does that work??? 🤔 ? ? ? ?
  • 15. docker-compose.yml Docker Compose Version Services in the Stack Configurations, Secrets, Storage Volumes, etc. Version: “3.7” services: nginx: image: nginx command: [ 'sh', '-c', "exec nginx -g 'daemon off;'" ] … php: image: php:7.3-fpm … network: web_frontend config: nginx.conf: file: ./nginx/nginx.conf volumes: …https://docs.docker.com/compose/compose-file/
  • 17. SIDEBAR:The Docker Hierarchy Image Container Service Stack
  • 18. SIDEBAR:The Docker Hierarchy Image Container Service Stack Node Swarm
  • 19. > docker stack deploy … Swarm NODE 1 NODE 2 ETC. PHP 1 MySQL NGINX PHP 2
  • 20. SIDEBAR:Docker Command Syntax docker (object) (action) (args)
  • 21. SIDEBAR:Docker Command Syntax docker (object) (action) (args) > docker container ls
  • 22. SIDEBAR:Docker Command Syntax docker (object) (action) (args) > docker container ls > docker image ls
  • 23. SIDEBAR:Docker Command Syntax docker (object) (action) (args) > docker container ls > docker image ls > docker service ls
  • 24. SIDEBAR:Docker Command Syntax docker (object) (action) (args) > docker container ls > docker image ls > docker service ls > docker volume ls
  • 25. 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
  • 26. 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
  • 28. Node Manager A SWARM OF ONE > docker swarm init
  • 29. Node Manager A SWARM OF ONE > docker swarm init
  • 30. ⚠ Common “Gotcha” Swarm init — ONE TIME ONLY * THE SWARM PERSISTS *
  • 31. ⚠ Common “Gotcha” Swarm init — ONE TIME ONLY * THE SWARM PERSISTS * > docker swarm leave
  • 32. ⚠ Common “Gotcha” Swarm init — ONE TIME ONLY * THE SWARM PERSISTS * > docker swarm leave > docker swarm leave —force
  • 34. POPQUIZ! A. What’s the difference between a container and a service?
  • 35. POPQUIZ! A. What’s the difference between a container and a service? B. What’s the difference between a service and a stack?
  • 41. Images for Automated Testing selenium/standalone-chrome-debug selenium/standalone-firefox-debug:2.53.0 acceptance.suite.yml docker-compose.yml
  • 42. Images for Automated Testing selenium/standalone-chrome-debug selenium/standalone-firefox-debug:2.53.0 acceptance.suite.yml docker-compose.yml
  • 43. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune
  • 44. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune > docker system prune
  • 45. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune > docker system prune
  • 46. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune > docker system prune
  • 47. SIDEBAR:Legacy images, containers, volumes > docker image prune > docker container prune > docker (whatever) prune > docker system prune
  • 48. version: “3.7” 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.3-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.3-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.3 FPM NGINX MySQL
  • 49. php: image: php:7.3-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.3-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 version: “3.7” 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 7.0 FPM NGINX MySQL
  • 50. php: image: php:7.3-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.3-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 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;’”] PHP 7.0 FPM NGINX MySQL
  • 51. php: image: php:7.3-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.3-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 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;’”] PHP 7.0 FPM NGINX MySQL
  • 52. SIDEBAR:LABELS — use them everywhere! 🤔 ? ? ? ? The -f toggle -f name=phpworld_php -f label=com.envisage.desc=php
  • 53. SIDEBAR:LABELS — use them everywhere! 🤔 ? ? ? ? The -f toggle -f name=phpworld_php -f label=com.envisage.desc=php
  • 54. SIDEBAR:LABELS — use them everywhere! 🤔 ? ? ? ? The -f toggle -f name=phpworld_php -f label=com.envisage.desc=php
  • 55. SIDEBAR:LABELS — use them everywhere! 🤔 ? ? ? ? The -f toggle -f name=phpworld_php -f label=com.envisage.desc=php
  • 56. version: “3.7” 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
  • 57. Volume Example for php php: volumes: - ./public_html:/var/ www/html Local path relative to the file Path location within the container
  • 58. 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”
  • 59. Using named storage volumes > docker volume create pub_html —opt type=none —opt o=bind —opt device=/Volumes/E/site/ —label “com.envisage.desc=Site”
  • 60. ⚠ Common “Gotcha” * BEWARE WINDOWS PATHS * C:DockerDriveSite /C/DockerDrives/Site /host_mnt/c/DockerDrives/Site //c/DockerDrives/Site Windows LCOW Volume Path
  • 63. POPQUIZ! A. What is the command to initialize a swarm?
  • 64. POPQUIZ! A. What is the command to initialize a swarm? B. What is the command to deploy a docker stack?
  • 65. > docker stack deploy -c docker-compose.yml phpworld
  • 66. > docker stack deploy -c docker-compose.yml phpworld
  • 67. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ?
  • 68. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls
  • 69. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls
  • 70. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls
  • 71. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls
  • 72. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls > docker stack ps phpworld
  • 73. > docker stack deploy -c docker-compose.yml phpworld 🤔 ? ? ? ? > docker service ls > docker stack ps phpworld
  • 74. > docker service logs phpworld_db
  • 75. > docker service logs phpworld_db
  • 76. > docker service logs phpworld_db
  • 77. > docker service logs phpworld_db
  • 80. Want to see it in action? > docker service logs phpworld_nginx -f
  • 81. Want to see it in action? > docker service logs phpworld_nginx -f
  • 83. ⚠ Common “Gotcha” localhost:3306 db:3306 upstream fastcgi { server 127.0.0.1:9000 } upstream fastcgi { server php:9000 }
  • 84. Ok, great! But … ¯_(ツ)_/¯ My production server has lots of configurations that have been customized… php/conf.d/* my.cnf nginx.conf nginx/conf.d/*
  • 85. version: “3.7” 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.3-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.3-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
  • 86. version: “3.7” 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 networks: - web deploy: replicas: 1 restart_policy: condition: on-failure labels: com.envisageinternational.d volumes: - ./public_html:/var/ www/html labels: com.envisageinternational.de command: [‘bin/sh’, ‘-c’, “sleep networks: web: configs: mysite: file: ./mysite.conf secrets: PHP 7.0 FPM NGINX MySQL
  • 88. Config: mysite > docker config inspect phpworld_mysite
  • 89. 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.3-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.3-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
  • 91. Secret: db_pwd > docker secret inspect phpworld_db_pwd
  • 92. ⚠ Common “Gotcha” > docker config ls
  • 93. ⚠ Common “Gotcha” > docker config ls
  • 94. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls
  • 95. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls
  • 96. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls
  • 97. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls
  • 98. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls > docker service update --config-rm phpworld_mysite --config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf phpworld_nginx
  • 99. ⚠ Common “Gotcha” > docker config create mysite.2 ./mysite.conf > docker config ls > docker service update --config-rm phpworld_mysite --config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf phpworld_nginx
  • 101. > docker service rollback phpworld_nginx
  • 102. > docker service rollback phpworld_nginx
  • 103. Done with the project for now? > docker stack rm phpworld
  • 104. Done with the project for now? > docker stack rm phpworld
  • 105. Done with the project for now? > docker stack rm phpworld
  • 106. Done with the project for now? > docker stack rm phpworld
  • 108. POPQUIZ! A. How do you check the replication status of services?
  • 109. POPQUIZ! A. How do you check the replication status of services? B. How do you check for error messages on the stack?
  • 110. POPQUIZ! A. How do you check the replication status of services? B. How do you check for error messages on the stack? BONUS POINT
  • 111. POPQUIZ! A. How do you check the replication status of services? B. How do you check for error messages on the stack? BONUS POINT How do you avoid truncating the error message?
  • 112. 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?
  • 113. Same project … multiple production targets? docker-compose.yml docker-compose-clientA.yml docker-compose-clientB.yml
  • 114. Same project … multiple production targets? docker-compose.yml docker-compose-clientA.yml docker-compose-clientB.yml
  • 115. Same project … multiple production targets? docker-compose.yml docker-compose-clientA.yml docker-compose-clientB.yml
  • 116. Same project … multiple production targets? docker-compose.yml docker-compose-clientA.yml docker-compose-clientB.yml
  • 118. POPQUIZ! A. How do you filter a list of docker objects (services, containers, images, etc)
  • 119. SIDEBAR:The $( ) magic with -q -l -f -q Quiet (ID only) -l Last Updated Only (1 result) -f Filter (you remember this)
  • 120. 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
  • 121. 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
  • 122. 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 -lq -f name=phpworld_nginx) bash
  • 123. 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 -lq -f name=phpworld_nginx) bash
  • 124. Don’t love the command prompt?
  • 125. 🤔 ? ? ?? Don’t love the command prompt?
  • 129. POPQUIZ!A. What is the command to deploy a stack?
  • 130. POPQUIZ!A. What is the command to deploy a stack?
  • 136. > docker image build -f images/Dockerfile-bundled --target=phpworld_php -t dhluther/php:phpworld-demo . > docker image build -f images/Dockerfile-bundled --target=phpworld_nginx -t dhluther/nginx:phpworld-demo .
  • 142. POPQUIZ!A. Command line equivalent?
  • 143. POPQUIZ!A. Command line equivalent? > docker service ls -f name=phpworld
  • 147. POPQUIZ!A. Command line equivalent?
  • 148. POPQUIZ!A. Command line equivalent? > docker container ls
  • 150. > docker container exec -it $(docker ps -lq -f name=phpworld_php) bash
  • 154. > docker service update --config-add source=mysite.2,target=/etc/nginx/conf.d/default.conf phpworld_nginx Command line equivalent?