SlideShare a Scribd company logo
1 of 55
Download to read offline
Preparing your dockerised application for
production deployment
Dave Ward
Globe Online Ltd
PHP UK Conference
17th Feb 2017
Docker Benefits For Us
• Quick to setup dev environments
• Identical environments
• Flexible resource allocation
• Test site creation
• Confidence in deployment
• Stable releases
• Amazing rollbacks
• Easy scaling
• Trivial Service Upgrades
• Easy Continuous Deployment
• Simple Configurations
• Increased Productivity
• “It worked on my machine”
• Lightweight
• Fewer Production Incidents
• Zero Failed Releases
• EnvironmentVersion Control
• Resource Isolation
• More Frequent Releases
Who Uses Docker In Development?
Who Uses Docker In Production?
What is Docker?What is Docker?
http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/
‘Development’ Images
• Based from trusted image
• Mounted code that’s been committed to a custom image
• Pushed to an image repository
• No environment/secrets management
• Dependencies installed post container start
• Possibly setup with series docker run commands
• Mounted volumes allow IDE usage
run
push
Dependencies
commit
IMAGE
Docker in Development
CONTAINER
build
pull
mount
These are great for
• Speed
• Getting developers up and running
• Development environment Consistency
• Only need docker to develop
• IDE development
Issues
• No accountability of image creation
• Not transparent
• Not fit for scaling
• Environment Specific
• No logging
• Disorganised repository
• Not Immutable
Production Image Goals
Immutable Ephemeral
Production ready artefacts
• Automated Builds
• Application Code
• Pre-installed dependencies
• Composer
• Bower
• Environment Capable
docker run
Dependencies
IMAGE
Docker in Production
CONTAINER
docker build
A proposed
repository structure
• Your repository is now one level up.
• Project environment is now under version
control
• /appcode : application code only
• /appdata : data only container of appcode
• docker-compose.override.yml
• Dockerfile.build
• docker-compose.prodsite.yml
• /[services]
The Power of Three
git clone git@bitbucket.org:you/your-app.git
cd your-app
docker-compose up -d
Automated Builds
• Builds a deployment artefact
• Automatic or manual trigger
• Error Handling
• Build context taken from Dockerfile location
• Repository Links
• Remote Build triggers
• Webhooks
• Dockerhub does not use cached layers
git clone davidsimonward/phpukconference.git
cd phpukconference
git checkout -b develop
docker build -f Dockerfile.build -t davidsimonward/phpukconference:latest .
docker push davidsimonward/phpukconference:latest
Advantages
• Images built in this way are built exactly as specified.
• The Dockerfile is available to anyone with access to your
Docker Hub repository.
• Your image repository is kept up-to-date with code changes
automatically.
Application Code
run
push
Dependencies
commit
IMAGE
Docker in Development
CONTAINER
build
pull
mount
docker run
Dependencies
IMAGE
Docker in Production
CONTAINER
docker build
Development Production
Dockerfile instructs
application code to be
copied into the phpfpm
image on build.
Application Code is
exposed for Nginx
container.
Application code is
mounted into data only
container.
Nginx and PHP-FPM
use volumes from this
container
DEMO
Dependencies
run
push
Dependencies
commit
IMAGE
Docker in Development
CONTAINER
build
pull
mount
docker run
Dependencies
IMAGE
Docker in Production
CONTAINER
docker build
Development Production
Dependencies installed
as part of the docker
image build.
Instructions in
Dockerfile.build
Dependencies installed post container run.
docker run --rm -v $(pwd):/app
composer/composer install -vvv
—ignore-platform-reqs
docker exec -it
PHPUKConference composer
install -vvv
Entrypoint script
DEMO
Private Dependencies?
Base Image
Config/Secrets
Some Solutions
• ‘Baking’ it into the image
• EnvironmentVariables
• Volume Mounts
• Secrets Store
• Orchestration Specific Solutions
Docker Secrets
• Docker 1.13
• Only currently available to swarm services
• Manages
• Usernames and passwords
• TLS certificates and keys
• SSH keys
• Other important data such as the name of a database or internal
server
• Generic strings or binary content (up to 500 kb in size)
• echo "noway-caiman-mumble" | docker secret create db_password -
• docker service create --secret="db_password"…….. -e
DB_PASSWORD_FILE=“/run/secrets/db_password" my:image
https://docs.docker.com/engine/swarm/secrets/
Simple Example
Start preparing your images now!
Logging Strategies
DataVolumes
• Store logs in data volume on host
• Reduce chances of data loss due to failed container
• Easy to backup host volume
• Not good for elastic architecture
When to use?
• On non-production systems when longer lasting logs are required.
Docker Logging Driver
• Reads stdout and stderr output generated by containers
• `docker run --log-driver syslog ……`
• Native to Docker
• Easy to configure
• Centralises logs in a single location
When to use?
• Quick and easy solution when customised application logs are not
required.
Application Logging
• Each container uses internal methods for logging
• Logging Framework
• Monolog
• Easy to implement
• Applications independent of containers and host
• Highly Customisable
• Performance Overhead?
When to use?
• Use when you require a high degree of control over each application’s
logging implementation
Dedicated Logging Container
• Manage logging from within Docker environment
• Part of architecture
• Removes dependencies on the host machine
• Simplifies scaling
• Application containers need to be aware of the logging container, and
vice versa
When to use?
• Use when you’d like a more flexible logging architecture with a central
place to aggregate logs.
Logging via Sidecar
• Similar to dedicated container for logging
• Each container has it’s own dedicated logging container
• Fully customise each application’s logging solution
• Both the application and logging container must be treated as a single
unit
• Difficult to set up
• May consume more resources than a dedicated logging solution
When to use?
• Use in a large, distributed architecture where you still need fine-tuned
control over your logging solution
Other Processes
Supervisord
• Run more than one process in container
• Benefits
• Greater Control of processes
• Better management of processes
• Base Image
• PHP-FPM
• Crontab
• Workers
Container Monitoring
Container Metrics of interest
• Container CPU –Throttled CPUTime
• Container Memory – Fail Counters
• Container Memory Usage
• Container Swap
• Container Disk I/O
• Container Network Metrics
Monitoring Solutions
Common Mistakes
• Creating images from running containers
• Deploying with ‘latest’ tag
• Storing credentials in the image.
• Creating images from running containers
• Doing too much in your run.sh script (e.g. composer install)
• Leads to really a long start up time
• Relying on IP Addresses
Deployment Process
• UpdateTask Definition
• Image for phpfpm container is updated
• Update Service to use newTask Definition
• Easily roll back to previousTask Definition
• Immutable!
• Confidence
• Zero downtime deployments
• Draining Connections
Questions?

More Related Content

What's hot

Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013dotCloud
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldzekeLabs Technologies
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionHao Fan
 
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...Odinot Stanislas
 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDocker, Inc.
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersYajushi Srivastava
 
Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok   Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok Docker, Inc.
 
Developing with Docker for the Arm Architecture
Developing with Docker for the Arm ArchitectureDeveloping with Docker for the Arm Architecture
Developing with Docker for the Arm ArchitectureDocker, Inc.
 
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker, Inc.
 
Containers and microservices for realists
Containers and microservices for realistsContainers and microservices for realists
Containers and microservices for realistsKarthik Gaekwad
 
Docker Registry V2
Docker Registry V2Docker Registry V2
Docker Registry V2Docker, Inc.
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to MicroservicesDavid Currie
 
IIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and DockerIIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and DockerPradeep Natarajan
 
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...Docker, Inc.
 
Docker introduction & benefits
Docker introduction & benefitsDocker introduction & benefits
Docker introduction & benefitsAmit Manwade
 
DCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at NetflixDCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at NetflixDocker, Inc.
 
Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containersactualtechmedia
 

What's hot (20)

Intro Docker october 2013
Intro Docker october 2013Intro Docker october 2013
Intro Docker october 2013
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Docker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container worldDocker - A curtain raiser to the Container world
Docker - A curtain raiser to the Container world
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
Bare-metal, Docker Containers, and Virtualization: The Growing Choices for Cl...
 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok   Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok
 
Developing with Docker for the Arm Architecture
Developing with Docker for the Arm ArchitectureDeveloping with Docker for the Arm Architecture
Developing with Docker for the Arm Architecture
 
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, SollianceDocker for .NET Developers - Michele Leroux Bustamante, Solliance
Docker for .NET Developers - Michele Leroux Bustamante, Solliance
 
Docker-Intro
Docker-IntroDocker-Intro
Docker-Intro
 
Containers and microservices for realists
Containers and microservices for realistsContainers and microservices for realists
Containers and microservices for realists
 
Docker Registry V2
Docker Registry V2Docker Registry V2
Docker Registry V2
 
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
Developing Enterprise Applications for the Cloud,from Monolith to MicroservicesDeveloping Enterprise Applications for the Cloud,from Monolith to Microservices
Developing Enterprise Applications for the Cloud, from Monolith to Microservices
 
IIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and DockerIIUG 2017 Conference - Informix and Docker
IIUG 2017 Conference - Informix and Docker
 
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...
Docker Networking in Production at Visa - Sasi Kannappan, Visa and Mark Churc...
 
Docker introduction & benefits
Docker introduction & benefitsDocker introduction & benefits
Docker introduction & benefits
 
DCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at NetflixDCSF19 Container Security: Theory & Practice at Netflix
DCSF19 Container Security: Theory & Practice at Netflix
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Virtualization Vs. Containers
Virtualization Vs. ContainersVirtualization Vs. Containers
Virtualization Vs. Containers
 

Viewers also liked

Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Michele Orselli
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Colin O'Dell
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPChris Tankersley
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through ExamplesCiaranMcNulty
 
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017Alena Holligan
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)James Titcumb
 
JWT - To authentication and beyond!
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!Luís Cobucci
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTPHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTAdam Englander
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with DockerPatrick Mizer
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXNGINX, Inc.
 
WordPress for the modern PHP developer
WordPress for the modern PHP developerWordPress for the modern PHP developer
WordPress for the modern PHP developerChris Sherry
 
Docker Novosibirsk Meetup #3 - Docker in Production
Docker Novosibirsk Meetup #3 - Docker in ProductionDocker Novosibirsk Meetup #3 - Docker in Production
Docker Novosibirsk Meetup #3 - Docker in ProductionGianluca Arbezzano
 
Revised version of design, production, application and analysis of tblt march...
Revised version of design, production, application and analysis of tblt march...Revised version of design, production, application and analysis of tblt march...
Revised version of design, production, application and analysis of tblt march...Clara Clavijo Encalada
 
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHDocker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHagilemethoden
 
How the real-time communication between things can simplify our everyday lif...
How the real-time communication between things can simplify  our everyday lif...How the real-time communication between things can simplify  our everyday lif...
How the real-time communication between things can simplify our everyday lif...Karina Popova
 
OOP 2012 - Udo Pracht - DevOps Einführung und Überblick
OOP 2012 - Udo Pracht - DevOps Einführung und ÜberblickOOP 2012 - Udo Pracht - DevOps Einführung und Überblick
OOP 2012 - Udo Pracht - DevOps Einführung und ÜberblickUdo Pracht
 
Docker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM productsDocker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM productsAndrea Fontana
 
Docker進階探討
Docker進階探討Docker進階探討
Docker進階探討國昭 張
 
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...Baruch Sadogursky
 

Viewers also liked (20)

Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17Hopping in clouds - phpuk 17
Hopping in clouds - phpuk 17
 
Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017Debugging Effectively - PHP UK 2017
Debugging Effectively - PHP UK 2017
 
Docker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHPDocker for Developers - Sunshine PHP
Docker for Developers - Sunshine PHP
 
Driving Design through Examples
Driving Design through ExamplesDriving Design through Examples
Driving Design through Examples
 
Drupal8 for Symfony Developers
Drupal8 for Symfony DevelopersDrupal8 for Symfony Developers
Drupal8 for Symfony Developers
 
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017Demystifying Object-Oriented Programming - PHP UK Conference 2017
Demystifying Object-Oriented Programming - PHP UK Conference 2017
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
JWT - To authentication and beyond!
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!
 
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your RESTPHP UK 2017 - Don't Lose Sleep - Secure Your REST
PHP UK 2017 - Don't Lose Sleep - Secure Your REST
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Load Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINXLoad Balancing Apps in Docker Swarm with NGINX
Load Balancing Apps in Docker Swarm with NGINX
 
WordPress for the modern PHP developer
WordPress for the modern PHP developerWordPress for the modern PHP developer
WordPress for the modern PHP developer
 
Docker Novosibirsk Meetup #3 - Docker in Production
Docker Novosibirsk Meetup #3 - Docker in ProductionDocker Novosibirsk Meetup #3 - Docker in Production
Docker Novosibirsk Meetup #3 - Docker in Production
 
Revised version of design, production, application and analysis of tblt march...
Revised version of design, production, application and analysis of tblt march...Revised version of design, production, application and analysis of tblt march...
Revised version of design, production, application and analysis of tblt march...
 
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbHDocker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
Docker Workshop Experten Forum Stuttgart 2015, Agile Methoden GmbH
 
How the real-time communication between things can simplify our everyday lif...
How the real-time communication between things can simplify  our everyday lif...How the real-time communication between things can simplify  our everyday lif...
How the real-time communication between things can simplify our everyday lif...
 
OOP 2012 - Udo Pracht - DevOps Einführung und Überblick
OOP 2012 - Udo Pracht - DevOps Einführung und ÜberblickOOP 2012 - Udo Pracht - DevOps Einführung und Überblick
OOP 2012 - Udo Pracht - DevOps Einführung und Überblick
 
Docker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM productsDocker, how to use it. Organize a meeting with IBM products
Docker, how to use it. Organize a meeting with IBM products
 
Docker進階探討
Docker進階探討Docker進階探討
Docker進階探討
 
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
Patterns and antipatterns in Docker image lifecycle as was presented at Oracl...
 

Similar to Preparing your dockerised application for production deployment

IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM France Lab
 
Docker for developers - The big picture
Docker for developers - The big pictureDocker for developers - The big picture
Docker for developers - The big pictureGeorge Dyrrahitis
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDocker, Inc.
 
Docker crash course
Docker crash courseDocker crash course
Docker crash coursenispas
 
Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifeidotCloud
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsRamit Surana
 
Lightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeLightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeDocker, Inc.
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture materialAnkit Gupta
 
Using Docker in production: Get started today!
Using Docker in production: Get started today!Using Docker in production: Get started today!
Using Docker in production: Get started today!Clarence Bakirtzidis
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerWeb à Québec
 
Securing Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupSecuring Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupKumar Ashwin
 
Securing Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupSecuring Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupKumar Ashwin
 

Similar to Preparing your dockerised application for production deployment (20)

IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
IBM Bluemix Paris Meetup #14 - Le Village by CA - 20160413 - Introduction à D...
 
Containers 101
Containers 101Containers 101
Containers 101
 
Informix on Docker Hub
Informix on Docker HubInformix on Docker Hub
Informix on Docker Hub
 
Docker for developers - The big picture
Docker for developers - The big pictureDocker for developers - The big picture
Docker for developers - The big picture
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Docker crash course
Docker crash courseDocker crash course
Docker crash course
 
Docker in pratice -chenyifei
Docker in pratice -chenyifeiDocker in pratice -chenyifei
Docker in pratice -chenyifei
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Docker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and toolsDocker for the new Era: Introducing Docker,its components and tools
Docker for the new Era: Introducing Docker,its components and tools
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker presentation for sharing
Docker presentation   for sharingDocker presentation   for sharing
Docker presentation for sharing
 
Lightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in PracticeLightweight Virtualization Docker in Practice
Lightweight Virtualization Docker in Practice
 
Week 8 lecture material
Week 8 lecture materialWeek 8 lecture material
Week 8 lecture material
 
Using Docker in production: Get started today!
Using Docker in production: Get started today!Using Docker in production: Get started today!
Using Docker in production: Get started today!
 
Rami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with DockerRami Sayar - Node microservices with Docker
Rami Sayar - Node microservices with Docker
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
 
Securing Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupSecuring Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad Meetup
 
Securing Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad MeetupSecuring Containers From Day One | null Ahmedabad Meetup
Securing Containers From Day One | null Ahmedabad Meetup
 
Docker
DockerDocker
Docker
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Preparing your dockerised application for production deployment

  • 1. Preparing your dockerised application for production deployment Dave Ward Globe Online Ltd PHP UK Conference 17th Feb 2017
  • 2.
  • 3.
  • 4. Docker Benefits For Us • Quick to setup dev environments • Identical environments • Flexible resource allocation • Test site creation • Confidence in deployment • Stable releases • Amazing rollbacks • Easy scaling • Trivial Service Upgrades • Easy Continuous Deployment • Simple Configurations • Increased Productivity • “It worked on my machine” • Lightweight • Fewer Production Incidents • Zero Failed Releases • EnvironmentVersion Control • Resource Isolation • More Frequent Releases
  • 5. Who Uses Docker In Development?
  • 6. Who Uses Docker In Production?
  • 7.
  • 8. What is Docker?What is Docker? http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/
  • 9. ‘Development’ Images • Based from trusted image • Mounted code that’s been committed to a custom image • Pushed to an image repository • No environment/secrets management • Dependencies installed post container start • Possibly setup with series docker run commands • Mounted volumes allow IDE usage
  • 11. These are great for • Speed • Getting developers up and running • Development environment Consistency • Only need docker to develop • IDE development
  • 12. Issues • No accountability of image creation • Not transparent • Not fit for scaling • Environment Specific • No logging • Disorganised repository • Not Immutable
  • 14. Production ready artefacts • Automated Builds • Application Code • Pre-installed dependencies • Composer • Bower • Environment Capable
  • 15. docker run Dependencies IMAGE Docker in Production CONTAINER docker build
  • 16. A proposed repository structure • Your repository is now one level up. • Project environment is now under version control • /appcode : application code only • /appdata : data only container of appcode • docker-compose.override.yml • Dockerfile.build • docker-compose.prodsite.yml • /[services]
  • 17. The Power of Three git clone git@bitbucket.org:you/your-app.git cd your-app docker-compose up -d
  • 18. Automated Builds • Builds a deployment artefact • Automatic or manual trigger • Error Handling • Build context taken from Dockerfile location • Repository Links • Remote Build triggers • Webhooks • Dockerhub does not use cached layers
  • 19. git clone davidsimonward/phpukconference.git cd phpukconference git checkout -b develop docker build -f Dockerfile.build -t davidsimonward/phpukconference:latest . docker push davidsimonward/phpukconference:latest
  • 20. Advantages • Images built in this way are built exactly as specified. • The Dockerfile is available to anyone with access to your Docker Hub repository. • Your image repository is kept up-to-date with code changes automatically.
  • 23. docker run Dependencies IMAGE Docker in Production CONTAINER docker build
  • 24. Development Production Dockerfile instructs application code to be copied into the phpfpm image on build. Application Code is exposed for Nginx container. Application code is mounted into data only container. Nginx and PHP-FPM use volumes from this container
  • 25. DEMO
  • 28. docker run Dependencies IMAGE Docker in Production CONTAINER docker build
  • 29. Development Production Dependencies installed as part of the docker image build. Instructions in Dockerfile.build Dependencies installed post container run. docker run --rm -v $(pwd):/app composer/composer install -vvv —ignore-platform-reqs docker exec -it PHPUKConference composer install -vvv Entrypoint script
  • 30. DEMO
  • 34. Some Solutions • ‘Baking’ it into the image • EnvironmentVariables • Volume Mounts • Secrets Store • Orchestration Specific Solutions
  • 35.
  • 36.
  • 37.
  • 39. • Docker 1.13 • Only currently available to swarm services • Manages • Usernames and passwords • TLS certificates and keys • SSH keys • Other important data such as the name of a database or internal server • Generic strings or binary content (up to 500 kb in size)
  • 40. • echo "noway-caiman-mumble" | docker secret create db_password - • docker service create --secret="db_password"…….. -e DB_PASSWORD_FILE=“/run/secrets/db_password" my:image https://docs.docker.com/engine/swarm/secrets/ Simple Example Start preparing your images now!
  • 42. DataVolumes • Store logs in data volume on host • Reduce chances of data loss due to failed container • Easy to backup host volume • Not good for elastic architecture When to use? • On non-production systems when longer lasting logs are required.
  • 43. Docker Logging Driver • Reads stdout and stderr output generated by containers • `docker run --log-driver syslog ……` • Native to Docker • Easy to configure • Centralises logs in a single location When to use? • Quick and easy solution when customised application logs are not required.
  • 44. Application Logging • Each container uses internal methods for logging • Logging Framework • Monolog • Easy to implement • Applications independent of containers and host • Highly Customisable • Performance Overhead? When to use? • Use when you require a high degree of control over each application’s logging implementation
  • 45. Dedicated Logging Container • Manage logging from within Docker environment • Part of architecture • Removes dependencies on the host machine • Simplifies scaling • Application containers need to be aware of the logging container, and vice versa When to use? • Use when you’d like a more flexible logging architecture with a central place to aggregate logs.
  • 46. Logging via Sidecar • Similar to dedicated container for logging • Each container has it’s own dedicated logging container • Fully customise each application’s logging solution • Both the application and logging container must be treated as a single unit • Difficult to set up • May consume more resources than a dedicated logging solution When to use? • Use in a large, distributed architecture where you still need fine-tuned control over your logging solution
  • 48. Supervisord • Run more than one process in container • Benefits • Greater Control of processes • Better management of processes • Base Image • PHP-FPM • Crontab • Workers
  • 49.
  • 51. Container Metrics of interest • Container CPU –Throttled CPUTime • Container Memory – Fail Counters • Container Memory Usage • Container Swap • Container Disk I/O • Container Network Metrics
  • 53. Common Mistakes • Creating images from running containers • Deploying with ‘latest’ tag • Storing credentials in the image. • Creating images from running containers • Doing too much in your run.sh script (e.g. composer install) • Leads to really a long start up time • Relying on IP Addresses
  • 54. Deployment Process • UpdateTask Definition • Image for phpfpm container is updated • Update Service to use newTask Definition • Easily roll back to previousTask Definition • Immutable! • Confidence • Zero downtime deployments • Draining Connections