Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
讓軟體開發與應用更自由 - 使用 Docker 容器技術
Search
Yu-Lung Shao
June 25, 2017
Programming
95
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
讓軟體開發與應用更自由 - 使用 Docker 容器技術
20170625 台中自由軟體愛好者社群
#Docker
#LaraDock
Yu-Lung Shao
June 25, 2017
Other Decks in Programming
See All in Programming
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
ActionController meets Protocol Buffers
sorah
0
560
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
160
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
sbt 2.0: takeoff
eed3si9n
0
160
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.2k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
230
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Performance Optimization With LLMs
xleitix
0
140
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.9k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
211
25k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
My Coaching Mixtape
mlcsv
0
360
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
Mind Mapping
helmedeiros
1
400
Prompt Engineering for Job Search
mfonobong
0
520
Google's AI Overviews - The New Search
badams
0
1.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
Transcript
讓軟體開發與應⽤用更更⾃自由 使⽤用 docker 容器技術 2017.06.25 @台中⾃自由軟體愛好者社群(TFC)
講者 • 邵⽟玉龍 (Allen Shao) • 網路路暱稱:bestlong • 在⼿手⼯工具製造公司內擔任資訊⼈人員 •
程式開發、系統維運 • 持續學習探索 DevOps 中
⼤大綱 • Docker 基本概念念 • PHP 開發者的環境演變 • 會介紹 LaraDock
• 命令列列打字好累有沒有更更⽅方便便的管理理⼯工具 • Docker 使⽤用空間⼤大掃除
Docker 基本概念念
什什麼是 Docker? • Software Container Platform • Application delivery technology
• Not VMs • 比較像是隔離環境與共享資源⽽而不是模擬 • 獨棟房屋 vs 多住⼾戶公寓 Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.
Docker vs VM 圖片來來源 https://www.docker.com/what-container
VM Docker Size ⼤大 ⼩小 Startup 慢 快 Integration 不易易
容易易 簡單比較
Docker with VM 圖片來來源 https://www.docker.com/what-container
Why docker • Developer • 可以解決只在我的電腦可以正常運作的囧況 • 多⼈人協同開發讓開發環境統⼀一 • 新成員快速建置環境
• 經常要切換新舊環境版本 • Operator (System Admin) • build, ship, test, and deploy apps ⾃自動化 • Enterprise • DevOps, agile • cloud-ready, optimal costs
Docker Editions • Docker CE (Community Edition) • Stable •
Edge • Docker EE (Enterprise Edition) • Basic • Standard • Advanced • Moby ? • https://mobyproject.org/
Support Platform • Linux • apt-get install docker.io • macOS
• 舊版⽤用 boot2docker • Windows • 舊版⽤用 boot2docker • Win10 x64
Docker Engine 圖片來來源 https://docs.docker.com/engine/docker-overview/
• 三個基本要素 • Image 映像檔 • Container 容器 • Registry
(Repostory 倉庫) • 兩兩個基本必要 • 網路路 • ⾜足夠的硬碟空間
先來來感覺⼀一下 • 沒有環境的可先使⽤用線上服務 http://play-with-docker.com/ • docker version • docker info
• docker ps • docker images • docker pull hello-world • docker run hello-world • docker run -it ubuntu bash
Docker architecture Volumes dockerfile Client/Server 架構 圖片來來源 https://docs.docker.com/engine/docker-overview/
Docker 映像檔 • 唯讀的模板 • 分層結構,有層數上限 • 建立 Container 的模版
• Docker Hub https://hub.docker.com/
Docker 映像檔 分層結構圖⽰示 圖片來來源 https://blog.jayway.com/2015/03/21/a-not-very-short-introduction-to-docker/
Dockerfile • 打造映像檔的藍藍圖 • 需要具備 Linux 系統管理理的知識
Dockerfile commands • 命令有效範圍區分為建構時期與啟動容器時期 Build Both (Build/Run) Run FROM MAINTAINER
COPY ADD RUN ONBUILD .dockerignore WORKDIR USER CMD ENV EXPOSE VOLUME ENTRYPOINT https://docs.docker.com/engine/reference/builder/ 第⼀一個指令必須為 ‘FROM’
Dockerfile 設計原則 • 先求正確建構 • ⼀一個指令⼀一個 RUN • 再進⾏行行最佳化 •
減少映像檔分層 • ⽤用 && 合併 RUN 指令 • 容量量最⼩小化 • 不需要的檔案不要 ADD (應⽤用 .dockerignore) • 刪除暫存檔
Demo
PHP 開發者的⼯工作環境演變 使⽤用 HTTP + PHP + DB 組合
• Windows 開發環境 • ⼿手動安裝 • XAMPP • WampServer •
AppServ • 多重開機進入 Linux 環境 • 步驟繁瑣、版本固定 開發 PHP 演進 - 本機
開發 PHP 演進 - 遠端主機 • 在家中或公司架設主機 • Linux ⽤用
telnet, ssh, VNC 連入 • Windows ⽤用遠端桌⾯面連入 • 必須要有網路路
開發 PHP 演進 - 本機VM • VMware • VirtualBox •
Vargrant • ⽤用 vargrantfile ⾃自動化安裝、設定、管理理多個VM • 虛擬磁碟很佔⽤用空間 • VM 很耗資源,需要較⾼高階的電腦
開發 PHP 演進 - 本機容器 • docker 單⼀一容器全包 • 適合開發與測試,效能差
• docker 多個容器分散架構 • 指令太繁瑣,要對 Docker Network 熟悉 • docker-compose 多容器的管理理⼯工具 • 適合開發與⽣生產環境 • 預設設定檔 docker-compose.yml • 介紹使⽤用 LaraDock http://laradock.io/
Demo
命令列列打字好累有沒有 更更⽅方便便的管理理⼯工具
更更⽅方便便的管理理⼯工具 • GUI • Kitematic (MacOS、Windows) https://kitematic.com/ • WebUI •
Portainer https://portainer.io/ • Shipyard https://shipyard-project.com/ • Rancher http://rancher.com/rancher/ • Kubernetes https://kubernetes.io/
Docker 使⽤用空間⼤大掃除
Docker 玩著玩著就佔⽤用了了很多的硬 碟空間 • 三個需要清理理的部分 • 容器 • 映像檔 •
Volume • 強制釋放佔⽤用空間 (macOS)
清理理容器 刪除指定執⾏行行中容器 docker rm CONTAINER 刪除全部執⾏行行中容器 docker kill $(docker ps
-q) 刪除所有容器 docker rm $(docker ps -aq) 強制刪除所有容器 docker rm -f $(docker ps -aq) 刪除已停⽌止的容器 docker rm $(docker ps -aq -f status=exited) 請⼩小⼼心使⽤用:刪除容器會遺失讀寫層的資料 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/ps/#filtering
清理理映像檔 刪除指定映像檔 docker rmi IMAGE 刪除沒有建立容器的映像檔 docker rmi $(docker images
-q) 刪除沒有TAG的映像檔 docker rmi -f $(docker images -q -f dangling=true) 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/images/#filtering
清理理 Volume 刪除孤兒 volume docker volume rm $(docker volume ls
-q -f dangling=true) 強制刪除所有 volume docker volume rm -f $(docker volume ls -q) 請⼩小⼼心使⽤用:刪除 volume 會遺失資料 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/volume_ls/#filtering
強制釋放佔⽤用空間 (macOS) OOXX 該刪的都刪了了,怎麼 Host OS 磁碟空間還是沒釋放? 反正都刪光了了,試試看跑 Reset to
factory defaults
總結 • Docker 能更更快速的建置開發或⽣生產環境 • 讓系統架構即為程式碼 • 開發者學到 docker-compose 階段就很⾜足夠了了
• Volume ⼀一定要弄弄清楚,避免發⽣生資料遺失事件
學習資源 • https://docs.docker.com/ • Docker — 從入⾨門到實踐 • https://www.gitbook.com/explore
Q&A