SlideShare a Scribd company logo
DOCKERINTRODUCTION TO CONTAINERS FOR
PHP DEVELOPERS
DOCKER - INTRODUCTION FOR PHP DEVELOPERS
MICHAŁ KURZEJA
▸ CTO at accesto.com
▸ michal@accesto.com
▸ @michalKurzeja
▸ Homebrewer
▸ Swimmer/runner
Docker - introduction
WHY
DOCKER?
Docker - introduction
DOCKER
SYSTEM DEPENDENCIES
DOCKER
SYSTEM DEPENDENCIES
PROJECT 1
PROJECT 2
PROJECT 3
* M
DOCKER
SYSTEM DEPENDENCIES
Developer 1
Tester
Developer 2
CI
Staging
* N
DOCKER - INTRODUCTION FOR PHP DEVELOPERS
PROJECT DEPENDENCY MATRIX FROM HELL
Dev Stage Prod CI
PHP ? ? ? ?
MySQL ? ? ? ?
Redis ? ? ? ?
RabbitMQ ? ? ? ?
Neo4j ? ? ? ?
Hadoop/
Spark
? ? ? ?
DOCKER - INTRODUCTION FOR PHP DEVELOPERS
PROJECT DEPENDENCY MATRIX FROM HELL
Dev Stage Prod CI
PHP ? ?
MySQL ? ? ?
Redis ? ? ? ?
RabbitMQ ? ? ? ?
Neo4j ? ? ? ?
Hadoop/
Spark
? ? ? ?
PROFITS?
BUILD ONCE,
EXECUTE
EVERYWHERE*
NO DEPENDENCY
& NO INCOMPATIBILITY
ISSUES
VM WITHOUT
OVERHEAD
FULLY
AUTOMATED
EASY
TO DEPLOY
SEPARATION
OF DUTIES
SCALABILITY
TECHNICAL
BACKGROUND
TEKST
VIRTUAL MACHINES VS CONTAINERS
TEKST
WHY IS DOCKER FAST?
IMAGE
IMAGE LAYER
imagelayers.io
CONTAINER
REPOSITORY
DOCKER HUB
DEMO TIME!
docker run docker/whalesay cowsay PHP!
docker run docker/whalesay cowsay PHP!
docker run docker/whalesay cowsay PHP!
docker run docker/whalesay cowsay PHP!
Docker - introduction
docker run -v $PWD:/var/www/html 

-p 8081:80 

php:5.6-apache
docker run -v $PWD:/var/www/html 

-p 8081:80 

php:5.6-apache
docker run -v $PWD:/var/www/html 

-p 8081:80 

php:5.6-apache 7.0-apache
Docker - introduction
Docker - introduction
READY TO
DIVE DEEPER?
OWN
DOCKER IMAGE
FROM docker/whalesay:latest
Dockerfile
FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes
Dockerfile
FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes

CMD /usr/games/fortune -a | cowsay
Dockerfile
FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes

CMD /usr/games/fortune -a | cowsay
docker build -t docker-whale .
Dockerfile
FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes

CMD /usr/games/fortune -a | cowsay
docker build -t docker-whale .
Dockerfile
FROM docker/whalesay:latest

RUN apt-get -y update && apt-get install -y fortunes

CMD /usr/games/fortune -a | cowsay
docker build -t docker-whale .



docker run docker-whale
Dockerfile
Docker - introduction
Docker - introduction
Docker - introduction
Docker - introduction
EVERYTHING IN ONE CONTAINER ?
MULTIPLE CONTAINERS!
DOCKER
COMPOSE
docker run -v $PWD/www:/var/www/html 

-p 8081:80 

php:7.0-apache
docker run -v $PWD/www:/var/www/html 

-p 8081:80 

php:7.0-apacheX
#docker-compose.yml
www:

image: php:7.0-apache
docker run -v $PWD/www:/var/www/html 

-p 8081:80 

php:7.0-apache
#docker-compose.yml
www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

docker run -v $PWD/www:/var/www/html 

-p 8081:80 

php:7.0-apache
#docker-compose.yml
www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

ports:

- 8081:80
docker run -v $PWD/www:/var/www/html 

-p 8081:80 

php:7.0-apache
#docker-compose.yml
www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

ports:

- 8081:80
docker-compose up
Docker - introduction
LINKING
CONTAINERS
WWW REDIS
www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

ports:

- 8081:80



redis:

image: redis
www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

ports:

- 8081:80

links:

- redis

redis:

image: redis
<?php
/* www/index.php */
require_once __DIR__.'/vendor/autoload.php';
$client = new PredisClient(['host' => 'redis']);
$counter = $client->incr('counter');
echo "Hostname: ".gethostname().PHP_EOL;
echo " Counter: ".$counter.PHP_EOL;
docker-compose ps
SCALING
APPLICATIONS
WWW REDIS
WWW
WWW
…
HAPROXY
version: '2'

services:

www:

image: php:7.0-apache

volumes: 

- ./www:/var/www/html

ports:

- 8081:80

links:

- redis

redis:

image: redis
version: '2'

services:

www: …

haproxy:

image: 'dockercloud/haproxy:latest'

redis: …
version: '2'

services:

www: …

haproxy:

image: 'dockercloud/haproxy:latest'

links:

- www

redis: …
version: '2'

services:

www: …

haproxy:

image: 'dockercloud/haproxy:latest'

links:

- www

ports:

- '80:80'

redis: …
version: '2'

services:

www: …

haproxy:

image: 'dockercloud/haproxy:latest'

links:

- www

ports:

- '80:80'

environment:

- DOCKER_TLS_VERIFY

- DOCKER_HOST

- DOCKER_CERT_PATH

volumes:

- $DOCKER_CERT_PATH:$DOCKER_CERT_PATH

redis: …
docker-compose up -d
docker-compose scale www=3
docker-compose ps
Docker - introduction
DEEPER?
DOCKER SWARM
MESOSPHERE
KUBERNETES
DOCKER
PACKAGING OWN APPLICATIONS
▸ Use Dockerfile
▸ COPY project code
▸ Orchestrate [with compose]
▸ Split into multiple containers
DOCKER
DEPLOYMENT TIPS&TRICKS
▸ Own in-house docker repository
▸ No direct disk usage
▸ Gaufrette - filesystem abstraction
▸ Logstash - logs
▸ Session in redis/memcached
CHALLENGE
ACCEPTED?
QUESTIONS?

More Related Content

PDF
Docker Introduction
PDF
Docker workshop
PDF
Docker Introduction + what is new in 0.9
PDF
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
PDF
Orchestrating Docker containers at scale
PPTX
Architecting .NET Applications for Docker and Container Based Deployments
PDF
PDF
Docker Introduction
Docker Introduction
Docker workshop
Docker Introduction + what is new in 0.9
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
Orchestrating Docker containers at scale
Architecting .NET Applications for Docker and Container Based Deployments
Docker Introduction

What's hot (20)

ODP
Docker - The Linux Container
ODP
Why Docker? Dayton PHP, April 2017
PDF
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
PDF
Wordcamp Bratislava 2017 - Docker! Why?
PDF
Docker Introduction
PDF
Visualising Basic Concepts of Docker
PPTX
Introduction to Docker
PDF
Docker introduction
PPT
Docker introduction
PDF
Introduction to Docker
PDF
Developer workflow with docker
PDF
Learning Docker with Thomas
PDF
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
PDF
Basic docker for developer
PPTX
Docker - 15 great Tutorials
PDF
Docker and the Linux Kernel
PDF
Intro to containerization
ODP
Ruby and Docker on Rails
PDF
Docker 101 @KACST Saudi HPC 2016
PDF
Shipping Applications to Production in Containers with Docker
Docker - The Linux Container
Why Docker? Dayton PHP, April 2017
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Wordcamp Bratislava 2017 - Docker! Why?
Docker Introduction
Visualising Basic Concepts of Docker
Introduction to Docker
Docker introduction
Docker introduction
Introduction to Docker
Developer workflow with docker
Learning Docker with Thomas
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Basic docker for developer
Docker - 15 great Tutorials
Docker and the Linux Kernel
Intro to containerization
Ruby and Docker on Rails
Docker 101 @KACST Saudi HPC 2016
Shipping Applications to Production in Containers with Docker
Ad

Viewers also liked (20)

PDF
From development environments to production deployments with Docker, Compose,...
PDF
A Gentle Introduction To Docker And All Things Containers
PDF
Docker by Example - Basics
PPTX
Docker introduction
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
PDF
How to deploy PHP projects with docker
PPTX
Docker Demystified - Virtual VMs without the Fat
PPTX
Working with kubernetes
PDF
Docker from basics to orchestration (PHPConfBr2015)
KEY
PDF
Oracle rac cachefusion - High Availability Day 2015
PPTX
Dockerize it all
PDF
Cloud conference - mongodb
PDF
Aman sharma hyd_12crac High Availability Day 2015
PPTX
Docker containers
PDF
RACATTACK Lab Handbook - Enable Flex Cluster and Flex ASM
PPTX
Kubernetes Basics
PDF
Docker Intro
PDF
Spark Application for Time Series Analysis
PDF
Flex Your Database on 12c's Flex ASM and Flex Cluster
From development environments to production deployments with Docker, Compose,...
A Gentle Introduction To Docker And All Things Containers
Docker by Example - Basics
Docker introduction
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
How to deploy PHP projects with docker
Docker Demystified - Virtual VMs without the Fat
Working with kubernetes
Docker from basics to orchestration (PHPConfBr2015)
Oracle rac cachefusion - High Availability Day 2015
Dockerize it all
Cloud conference - mongodb
Aman sharma hyd_12crac High Availability Day 2015
Docker containers
RACATTACK Lab Handbook - Enable Flex Cluster and Flex ASM
Kubernetes Basics
Docker Intro
Spark Application for Time Series Analysis
Flex Your Database on 12c's Flex ASM and Flex Cluster
Ad

Similar to Docker - introduction (20)

PDF
Developing and Deploying PHP with Docker
PDF
Docker for developers on mac and windows
PPTX
Running Docker in Development & Production (DevSum 2015)
PPTX
Docker for Web Developers: A Sneak Peek
PDF
Containerizing Web Application with Docker
PDF
Continuous Delivery with Docker and Jenkins pipeline
PDF
Docker: A New Way to Turbocharging Your Apps Development
PPTX
Running Docker in Development & Production (#ndcoslo 2015)
PPTX
Docker Container As A Service - Mix-IT 2016
PDF
Play With Docker
PDF
Cloud expo-east-2015
PDF
Docker module 1
PDF
Be a happier developer with Docker: Tricks of the trade
PDF
廣宣學堂: 容器進階實務 - Docker進深研究班
PDF
Docker 進階實務班
PDF
Be a Happier Developer with Docker: Tricks of the Trade
PDF
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
PPTX
Docker & Kubernetes
PDF
Docker, Kubernetes, and Google Cloud
PPTX
Getting started with Docker sandboxes for MariaDB
Developing and Deploying PHP with Docker
Docker for developers on mac and windows
Running Docker in Development & Production (DevSum 2015)
Docker for Web Developers: A Sneak Peek
Containerizing Web Application with Docker
Continuous Delivery with Docker and Jenkins pipeline
Docker: A New Way to Turbocharging Your Apps Development
Running Docker in Development & Production (#ndcoslo 2015)
Docker Container As A Service - Mix-IT 2016
Play With Docker
Cloud expo-east-2015
Docker module 1
Be a happier developer with Docker: Tricks of the trade
廣宣學堂: 容器進階實務 - Docker進深研究班
Docker 進階實務班
Be a Happier Developer with Docker: Tricks of the Trade
The Dockerfile Explosion and the Need for Higher Level Tools by Gareth Rushgrove
Docker & Kubernetes
Docker, Kubernetes, and Google Cloud
Getting started with Docker sandboxes for MariaDB

More from Michał Kurzeja (12)

PDF
Refactoring legacy systems using events commands and bubble contexts
PDF
Kolejkowanie w systemach multi-tenant - PHPCon 2023
PDF
Rozszerzalność Symfony - PHPCon 2023
PDF
Event-driven architecture, the easy way.pdf
PDF
Rozszerzalność aplikacji Symfony
PDF
Docker reverse proxy z użyciem Traefik
PDF
Symfony messenger - PHPers Summit 2019
PDF
Kubernetes - 0 do 1 - 4Developers Warszawa 2019
PDF
Strangler Pattern in practice @PHPers Day 2019
PPTX
Dr Strangler and Mr Hype - Strangler pattern w praktyce
PPTX
Serverless Architecture
PPTX
Symfony2 - garść porad
Refactoring legacy systems using events commands and bubble contexts
Kolejkowanie w systemach multi-tenant - PHPCon 2023
Rozszerzalność Symfony - PHPCon 2023
Event-driven architecture, the easy way.pdf
Rozszerzalność aplikacji Symfony
Docker reverse proxy z użyciem Traefik
Symfony messenger - PHPers Summit 2019
Kubernetes - 0 do 1 - 4Developers Warszawa 2019
Strangler Pattern in practice @PHPers Day 2019
Dr Strangler and Mr Hype - Strangler pattern w praktyce
Serverless Architecture
Symfony2 - garść porad

Recently uploaded (20)

PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
AI in Product Development-omnex systems
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPT
Introduction Database Management System for Course Database
PDF
Understanding Forklifts - TECH EHS Solution
PDF
System and Network Administration Chapter 2
PDF
Nekopoi APK 2025 free lastest update
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Introduction to Artificial Intelligence
PPTX
Transform Your Business with a Software ERP System
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PTS Company Brochure 2025 (1).pdf.......
Navsoft: AI-Powered Business Solutions & Custom Software Development
L1 - Introduction to python Backend.pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
AI in Product Development-omnex systems
CHAPTER 2 - PM Management and IT Context
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
ManageIQ - Sprint 268 Review - Slide Deck
Introduction Database Management System for Course Database
Understanding Forklifts - TECH EHS Solution
System and Network Administration Chapter 2
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
Introduction to Artificial Intelligence
Transform Your Business with a Software ERP System
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Odoo Companies in India – Driving Business Transformation.pdf
history of c programming in notes for students .pptx
Design an Analysis of Algorithms II-SECS-1021-03

Docker - introduction