Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How To Put Your Docker Image On A Diet
Search
Peter Fisher
September 26, 2019
Technology
0
200
How To Put Your Docker Image On A Diet
Talk given at PHP South Wales
Peter Fisher
September 26, 2019
Tweet
Share
More Decks by Peter Fisher
See All by Peter Fisher
Software Complexities
pfwd
0
180
Using a framework or not?
pfwd
1
230
How To Put Your Docker Image On A Diet | PHP South West
pfwd
1
260
Other Decks in Technology
See All in Technology
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
210
embedパッケージを深掘りする / Deep Dive into embed Package in Go
task4233
1
210
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
170
OPENLOGI Company Profile
hr01
0
58k
Formal Development of Operating Systems in Rust
riru
1
420
深層学習と3Dキャプチャ・3Dモデル生成(土木学会応用力学委員会 応用数理・AIセミナー)
pfn
PRO
0
460
Amazon Q Developerで.NET Frameworkプロジェクトをモダナイズしてみた
kenichirokimura
1
200
Building Scalable Backend Services with Firebase
wisdommatt
0
110
Goで実践するBFP
hiroyaterui
1
120
月間60万ユーザーを抱える 個人開発サービス「Walica」の 技術スタック変遷
miyachin
1
130
技術に触れたり、顔を出そう
maruto
1
150
Azureの開発で辛いところ
re3turn
0
240
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Rails Girls Zürich Keynote
gr2m
94
13k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Designing for humans not robots
tammielis
250
25k
A Philosophy of Restraint
colly
203
16k
How to Ace a Technical Interview
jacobian
276
23k
Transcript
PUT YOUR DOCKER IMAGE ON A DIET @PFWD @HowToCodeWell
SELF TAUGHT DOCKER DEV IF YOU SEE AN IMPROVEMENT PLEASE
LET ME KNOW WE ARE ALL LEARNING ALL THE TIME @PFWD @HowToCodeWell
PHP 7.4 RC 1 SYMFONY 4.3.6 APACHE 2 WEB SERVER
ORIGINAL 1.09GB AFTER DIET 171 MB @PFWD @HowToCodeWell
@PFWD @HowToCodeWell
WHY | WHAT | HOW @PFWD @HowToCodeWell
PETER FISHER BSC MBSC HOW TO CODE WELL
@PFWD @HowToCodeWell
WHY | WHAT | HOW @PFWD @HowToCodeWell
SPEED | SECURITY | SANITY | SCALABILITY @PFWD @HowToCodeWell
SPEED THE LIGHTER THE IMAGE THE FASTER THE DEVELOPMENT @PFWD
@HowToCodeWell
SPEED THE LIGHTER THE IMAGE THE FASTER THE DEPLOYMENT @PFWD
@HowToCodeWell
SPEED THE LIGHTER THE IMAGE THE FASTER THE DISTRIBUTION @PFWD
@HowToCodeWell
SECURITY THE SMALLER THE IMAGE THE SMALLER THE ATTACK SURFACE
@PFWD @HowToCodeWell
SECURITY DO NOT BAKE SECURITY CREDS INTO YOUR IMAGES @PFWD
@HowToCodeWell
SANITY THE SMALLER THE IMAGE THE LESS YOU HAVE TO
MAINTAIN @PFWD @HowToCodeWell
SANITY THE SMALLER THE IMAGE THE MORE CONTROL YOU HAVE
@PFWD @HowToCodeWell
SANITY THE SMALLER THE IMAGE THE QUICKER YOU CAN SPOT
PROBLEMS @PFWD @HowToCodeWell
SANITY THE SMALLER THE IMAGE THE LESS RESPONSIBILITY IT HAS
@PFWD @HowToCodeWell
SCALEABILITY THE SMALLER THE IMAGE THE QUICKER IT CAN INSTALL
@PFWD @HowToCodeWell
SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO EXPAND @PFWD
@HowToCodeWell
SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO CONTRACT @PFWD
@HowToCodeWell
SCALEABILITY THE SMALLER THE IMAGE THE QUICKER TO REUSE @PFWD
@HowToCodeWell
WHY | WHAT | HOW @PFWD @HowToCodeWell
WHAT IS THE DIFFERENCE BETWEEN A DOCKER CONTAINER AND A
VIRTUAL MACHINE? @PFWD @HowToCodeWell
@PFWD @HowToCodeWell
VIRTUALIZATION != CONTAINERIZATION @PFWD @HowToCodeWell
VIRTUALIZATION = IS A HOUSE @PFWD @HowToCodeWell
CONTAINERIZATION = IS A ROOM @PFWD @HowToCodeWell
DIFFERENT LEVELS OF ABSTRACTION @PFWD @HowToCodeWell
BOTH SOLVE DIFFERENT PROBLEMS @PFWD @HowToCodeWell
BOTH SHOULD BE USED DIFFERENTLY @PFWD @HowToCodeWell
VIRTUALIZATION CUSTOM ENVIRONMENT ALLOCATED RESOURCES ECOSYSTEM @PFWD @HowToCodeWell
CONTAINIZATION SINGLE PROCESS SINGLE RESPONSIBILITY SINGLE PURPOSE @PFWD @HowToCodeWell
WHAT IS A DOCKER IMAGE ANYWAY? @PFWD @HowToCodeWell
WHAT IS A DOCKER IMAGE ANYWAY? ANSWER: A FILE MADE
FROM MANY LAYERS WHICH CREATES A CONTAINER @PFWD @HowToCodeWell
CONTAINERS ARE BUILT FROM IMAGES @PFWD @HowToCodeWell
WHAT IS A DOCKER IMAGE MADE FROM? @PFWD @HowToCodeWell
WHAT IS A DOCKER IMAGE ANYWAY? ANSWER: MANY DIFFERENT IMAGES
@PFWD @HowToCodeWell
WHAT IS A DOCKER FILE? @PFWD @HowToCodeWell
WHAT IS A DOCKER FILE? ANSWER: A SERIES OF INSTRUCTIONS
THAT BUILD A DOCKER IMAGE @PFWD @HowToCodeWell
WHY | WHAT | HOW @PFWD @HowToCodeWell
VERSION 1.0.0 1.09 GB @PFWD @HowToCodeWell
VERSION 1.0.0 1.09 GB @PFWD @HowToCodeWell
26 BUILD STEPS 18 RUN INSTRUCTIONS VERSION 1.0.0 1.09 GB
@PFWD @HowToCodeWell
10 BUILD STEPS VERSION 1.1.0 1.06 GB @PFWD @HowToCodeWell
MULTIPLE CONTAINER RESPONSIBILITIES VERSION 1.1.0 1.06 GB @PFWD @HowToCodeWell
REMOVED MULTIPLE CONTAINER REPSONSIBILTES MYSQL-SERVER MYSQL-CLIENT RABBITMQ-SERVER VERSION 1.2.0 708MB
@PFWD @HowToCodeWell
DO NOT VERSION 1.2.0 708MB @PFWD @HowToCodeWell
REMOVED PHP-7.4-* VERSION 1.3.0 449MB @PFWD @HowToCodeWell
WRONG BASE IMAGE VERSION 1.3.0 449MB @PFWD @HowToCodeWell
VERSION 1.4.0 601MB USE PHP APACHE BASE IMAGE @PFWD @HowToCodeWell
VERSION 1.5.0 485MB @PFWD @HowToCodeWell
VERSION 1.6.0 478MB DON’T INSTALL RECOMENDED PACKAGES —no-install-recommends @PFWD @HowToCodeWell
VERSION 1.7.0 444MB MULTI STAGE DOCKER BUILD 3 STAGES! @PFWD
@HowToCodeWell
DEV PACKAGES SHOULD BE FOR DEV NOT FOR PROD! @PFWD
@HowToCodeWell
VERSION 1.8.0 424MB MULTI STAGE DOCKER BUILD 5 STAGES! 2
TARGETS NO DEV PACKAGES IN STAGING STAGING HAS AUTOLOADER DUMPED @PFWD @HowToCodeWell
VERSION 1.9.0 171MB ALPINE IMAGES DECOUPLING PHP FROM APACHE @PFWD
@HowToCodeWell
VERSION 1.9.0 88.5MB USE PHP FPM PHP AND APACHE ARE
IN 2 CONTAINERS @PFWD @HowToCodeWell
VERSION 1.9.0 PHP 88.5MB APACHE 171MB ER… HOW? @PFWD @HowToCodeWell
VERSION 1.9.0 PHP 88.5MB APACHE 171MB PROXY PHP REQUESTS TO
THE PHP CONTAINER @PFWD @HowToCodeWell
VERSION 1.9.0 PHP 88.5MB APACHE 171MB 1) USE THE PHP
SERVICE NAME 2) NETWORK APACHE AND PHP 3) SHARE THE SITE VOLUME @PFWD @HowToCodeWell
VERSION 1.9.0 PHP 88.5MB APACHE 171MB 1) USE THE PHP
SERVICE NAME 2) NETWORK APACHE AND PHP 3) SHARE THE SITE VOLUME @PFWD @HowToCodeWell
Version Size 1.0.0 1.0.9 GB 1.1.0 1.0.6 GB Reduced build
steps 1.2.0 708 MB Removed other responsibilities 1.3.0 449 MB Removed unknown PHP packages (php7.4-*) 1.4.0 601 MB Changed the base image 1.5.0 485 MB Removed package and composer cache 1.6.0 478 MB Didn’t install recommend packages 1.7.0 444 MB Used Multi Stage Docker Images 1.8.0 424 MB Removed dev composer packages 1.9.0 171 MB - Apache 88 MB - PHP Separated Apache and PHP @PFWD @HowToCodeWell
Peter Fisher BSC MBSC GITHUB https://github.com/pfwd/how-to-put- your-docker-image-on-a-diet Version 1.0.0 $
docker-compose up -d --build Grab a ☕ @PFWD @HowToCodeWell
Peter Fisher BSC MBSC THANK YOU QUESTIONS? LET ME KNOW
WHAT YOU THINK! @PFWD @HowToCodeWell